home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 22 / macformat_22.iso / Shareware / Programación / enteract-377 / enteract-377.sit / EnterAct Stuff / Documentation / Debugging hAWK programs < prev    next >
MacBinary  |  1992-04-05  |  17.1 KB  |  [TEXT/KEEN]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: MacBinary (archive/macBinary).

You can browse this item here: Debugging hAWK programs

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Sun Apr 5 12:25:02 1992, modified Sun Apr 5 12:25:02 1992, creator 'KEEN', type ASCII, 16705 bytes "Debugging hAWK programs" , at 0x41c1 582 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[KEEN]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 17 44 65 62 75 67 67 | 69 6e 67 20 68 41 57 4b |..Debugg|ing hAWK|
|00000010| 20 70 72 6f 67 72 61 6d | 73 00 00 00 00 00 00 00 | program|s.......|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4b 45 45 | 4e 01 00 00 00 00 00 00 |.TEXTKEE|N.......|
|00000050| 00 00 00 00 00 41 41 00 | 00 02 46 a6 04 da 5e a6 |.....AA.|..F...^.|
|00000060| 04 da 5e 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..^.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 b8 82 00 00 |........|........|
|00000080| 44 65 62 75 67 67 69 6e | 67 20 68 41 57 4b 20 70 |Debuggin|g hAWK p|
|00000090| 72 6f 67 72 61 6d 73 0d | 2d 2d 2d 2d 2d 2d 2d 2d |rograms.|--------|
|000000a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 0d 0d 49 6e 74 |--------|---..Int|
|000000b0| 72 6f 64 75 63 74 69 6f | 6e 0d 49 74 20 64 6f 65 |roductio|n.It doe|
|000000c0| 73 6e 27 74 20 72 75 6e | 0d 49 74 20 64 6f 65 73 |sn't run|.It does|
|000000d0| 6e 27 74 20 64 6f 20 77 | 68 61 74 20 49 20 77 61 |n't do w|hat I wa|
|000000e0| 6e 74 65 64 0d 43 6f 6d | 6d 6f 6e 20 62 75 67 73 |nted.Com|mon bugs|
|000000f0| 0d 0d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 0d 49 6e 74 72 |..------|---.Intr|
|00000100| 6f 64 75 63 74 69 6f 6e | 0d 2d 2d 2d 2d 2d 2d 2d |oduction|.-------|
|00000110| 2d 2d 0d 45 72 72 6f 72 | 73 20 63 61 6e 20 63 72 |--.Error|s can cr|
|00000120| 65 65 70 20 69 6e 20 61 | 74 20 74 68 65 20 73 70 |eep in a|t the sp|
|00000130| 65 63 69 66 69 63 61 74 | 69 6f 6e 2c 20 64 65 73 |ecificat|ion, des|
|00000140| 69 67 6e 2c 20 6f 72 20 | 63 6f 64 69 6e 67 20 73 |ign, or |coding s|
|00000150| 74 61 67 65 20 6f 66 20 | 61 6e 79 0d 70 72 6f 67 |tage of |any.prog|
|00000160| 72 61 6d 2c 20 69 6e 20 | 61 6e 79 20 6c 61 6e 67 |ram, in |any lang|
|00000170| 75 61 67 65 2e 20 53 79 | 6d 70 74 6f 6d 73 20 6f |uage. Sy|mptoms o|
|00000180| 66 20 61 20 65 72 72 6f | 72 20 63 61 6e 20 72 61 |f a erro|r can ra|
|00000190| 6e 67 65 20 66 72 6f 6d | 20 61 20 76 61 67 75 65 |nge from| a vague|
|000001a0| 0d 75 6e 65 61 73 69 6e | 65 73 73 20 61 62 6f 75 |.uneasin|ess abou|
|000001b0| 74 20 74 68 65 20 72 65 | 73 75 6c 74 73 20 74 6f |t the re|sults to|
|000001c0| 20 73 65 65 6d 69 6e 67 | 6c 79 20 72 61 6e 64 6f | seeming|ly rando|
|000001d0| 6d 20 63 72 61 73 68 65 | 73 2e 20 49 6e 20 43 2c |m crashe|s. In C,|
|000001e0| 20 6f 6e 65 20 6f 66 20 | 74 68 65 0d 6d 6f 73 74 | one of |the.most|
|000001f0| 20 64 69 66 66 69 63 75 | 6c 74 20 74 61 73 6b 73 | difficu|lt tasks|
|00000200| 20 6f 66 20 64 65 62 75 | 67 67 69 6e 67 20 69 73 | of debu|gging is|
|00000210| 20 74 6f 20 73 74 61 62 | 69 6c 69 7a 65 20 61 20 | to stab|ilize a |
|00000220| 62 75 67 20 73 6f 20 74 | 68 61 74 20 69 74 20 63 |bug so t|hat it c|
|00000230| 61 6e 20 62 65 0d 72 65 | 70 65 61 74 65 64 20 63 |an be.re|peated c|
|00000240| 6f 6e 73 69 73 74 65 6e | 74 6c 79 3b 20 66 6f 72 |onsisten|tly; for|
|00000250| 74 75 6e 61 74 65 6c 79 | 2c 20 69 6e 20 68 41 57 |tunately|, in hAW|
|00000260| 4b 20 74 68 69 73 20 69 | 73 6e 27 74 20 61 20 70 |K this i|sn't a p|
|00000270| 72 6f 62 6c 65 6d 2c 20 | 73 69 6e 63 65 20 69 74 |roblem, |since it|
|00000280| 0d 64 6f 65 73 6e 27 74 | 20 61 6c 6c 6f 77 20 77 |.doesn't| allow w|
|00000290| 72 69 74 69 6e 67 20 74 | 6f 20 61 6e 20 61 72 62 |riting t|o an arb|
|000002a0| 69 74 72 61 72 79 20 6d | 65 6d 6f 72 79 20 61 64 |itrary m|emory ad|
|000002b0| 64 72 65 73 73 2e 20 53 | 6f 20 66 6f 72 20 68 41 |dress. S|o for hA|
|000002c0| 57 4b 0d 70 72 6f 67 72 | 61 6d 73 2c 20 79 6f 75 |WK.progr|ams, you|
|000002d0| 72 20 74 61 73 6b 73 20 | 61 72 65 20 74 6f 20 66 |r tasks |are to f|
|000002e0| 69 6e 64 20 77 68 65 72 | 65 20 74 68 65 20 62 75 |ind wher|e the bu|
|000002f0| 67 20 69 73 2c 20 61 6e | 64 20 66 69 78 20 69 74 |g is, an|d fix it|
|00000300| 2e 0d 0d 54 68 69 73 20 | 69 73 20 6d 61 69 6e 6c |...This |is mainl|
|00000310| 79 20 61 20 67 75 69 64 | 65 20 74 6f 20 66 69 6e |y a guid|e to fin|
|00000320| 64 69 6e 67 20 77 68 65 | 72 65 20 74 68 65 20 62 |ding whe|re the b|
|00000330| 75 67 20 69 73 20 69 6e | 20 79 6f 75 72 20 73 6f |ug is in| your so|
|00000340| 75 72 63 65 20 63 6f 64 | 65 2c 20 77 69 74 68 20 |urce cod|e, with |
|00000350| 61 0d 62 72 69 65 66 20 | 6c 69 73 74 20 6f 66 20 |a.brief |list of |
|00000360| 63 6f 6d 6d 6f 6e 20 62 | 75 67 73 2e 20 57 68 65 |common b|ugs. Whe|
|00000370| 6e 20 69 74 27 73 20 6e | 6f 74 20 6f 62 76 69 6f |n it's n|ot obvio|
|00000380| 75 73 20 77 68 65 72 65 | 20 74 68 65 20 62 75 67 |us where| the bug|
|00000390| 20 69 73 2c 20 79 6f 75 | 72 20 74 77 6f 0d 62 65 | is, you|r two.be|
|000003a0| 73 74 20 77 65 61 70 6f | 6e 73 20 61 72 65 3b 20 |st weapo|ns are; |
|000003b0| 69 6e 73 65 72 74 20 22 | 70 72 69 6e 74 22 20 73 |insert "|print" s|
|000003c0| 74 61 74 65 6d 65 6e 74 | 73 20 74 6f 20 67 69 76 |tatement|s to giv|
|000003d0| 65 20 79 6f 75 20 73 6f | 6d 65 20 69 64 65 61 20 |e you so|me idea |
|000003e0| 6f 66 20 77 68 61 74 27 | 73 0d 67 6f 69 6e 67 20 |of what'|s.going |
|000003f0| 6f 6e 2c 20 61 6e 64 20 | 73 65 6c 65 63 74 69 76 |on, and |selectiv|
|00000400| 65 6c 79 20 63 6f 6d 6d | 65 6e 74 20 6f 75 74 20 |ely comm|ent out |
|00000410| 6c 69 6e 65 73 20 6f 66 | 20 73 6f 75 72 63 65 20 |lines of| source |
|00000420| 74 6f 20 69 73 6f 6c 61 | 74 65 20 74 68 65 20 70 |to isola|te the p|
|00000430| 72 6f 62 6c 65 6d 2e 0d | 42 75 74 20 61 73 20 79 |roblem..|But as y|
|00000440| 6f 75 20 67 61 69 6e 20 | 65 78 70 65 72 69 65 6e |ou gain |experien|
|00000450| 63 65 20 77 72 69 74 69 | 6e 67 20 68 41 57 4b 20 |ce writi|ng hAWK |
|00000460| 70 72 6f 67 72 61 6d 73 | 20 79 6f 75 27 6c 6c 20 |programs| you'll |
|00000470| 6e 61 74 75 72 61 6c 6c | 79 20 66 69 6e 64 0d 79 |naturall|y find.y|
|00000480| 6f 75 72 73 65 6c 66 20 | 61 76 6f 69 64 69 6e 67 |ourself |avoiding|
|00000490| 20 74 68 65 20 63 6f 6d | 6d 6f 6e 20 62 75 67 73 | the com|mon bugs|
|000004a0| 2c 20 61 6e 64 20 63 61 | 74 63 68 69 6e 67 20 74 |, and ca|tching t|
|000004b0| 68 65 20 6f 74 68 65 72 | 73 20 77 69 74 68 20 63 |he other|s with c|
|000004c0| 61 72 65 66 75 6c 0d 70 | 72 6f 6f 66 72 65 61 64 |areful.p|roofread|
|000004d0| 69 6e 67 2e 0d 0d 44 65 | 76 65 6c 6f 70 20 61 6e |ing...De|velop an|
|000004e0| 64 20 74 65 73 74 20 69 | 6e 20 73 6d 61 6c 6c 20 |d test i|n small |
|000004f0| 70 69 65 63 65 73 2e 20 | 46 6f 6c 6c 6f 77 20 61 |pieces. |Follow a|
|00000500| 20 70 6c 61 6e 2e 20 44 | 6f 6e 27 74 20 67 65 74 | plan. D|on't get|
|00000510| 20 6d 61 64 2c 20 67 65 | 74 20 63 72 69 74 69 63 | mad, ge|t critic|
|00000520| 61 6c 2e 0d 51 75 65 73 | 74 69 6f 6e 20 65 76 65 |al..Ques|tion eve|
|00000530| 72 79 74 68 69 6e 67 2c | 20 69 6e 63 6c 75 64 69 |rything,| includi|
|00000540| 6e 67 20 74 68 69 73 20 | 63 68 65 61 70 20 61 64 |ng this |cheap ad|
|00000550| 76 69 63 65 2e 0d 0d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |vice...-|--------|
|00000560| 0d 49 74 20 64 6f 65 73 | 6e 27 74 20 72 75 6e 0d |.It does|n't run.|
|00000570| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 0d 49 66 20 79 6f 75 |--------|-.If you|
|00000580| 72 20 70 72 6f 67 72 61 | 6d 20 64 6f 65 73 6e 27 |r progra|m doesn'|
|00000590| 74 20 73 74 61 72 74 20 | 72 75 6e 6e 69 6e 67 20 |t start |running |
|000005a0| 64 75 65 20 74 6f 20 61 | 20 73 79 6e 74 61 78 20 |due to a| syntax |
|000005b0| 65 72 72 6f 72 2c 20 74 | 68 65 0d 22 24 74 65 6d |error, t|he."$tem|
|000005c0| 70 53 74 64 45 72 72 22 | 20 66 69 6c 65 20 77 69 |pStdErr"| file wi|
|000005d0| 6c 6c 20 63 6f 6e 74 61 | 69 6e 20 61 20 6d 65 73 |ll conta|in a mes|
|000005e0| 73 61 67 65 20 74 65 6c | 6c 69 6e 67 20 79 6f 75 |sage tel|ling you|
|000005f0| 20 74 68 65 20 6c 69 6e | 65 20 6e 75 6d 62 65 72 | the lin|e number|
|00000600| 0d 77 68 65 72 65 20 74 | 68 65 20 65 72 72 6f 72 |.where t|he error|
|00000610| 20 77 61 73 20 64 65 74 | 65 63 74 65 64 2e 20 4e | was det|ected. N|
|00000620| 6f 72 6d 61 6c 6c 79 20 | 74 68 69 73 20 6c 69 6e |ormally |this lin|
|00000630| 65 20 6e 75 6d 62 65 72 | 20 77 69 6c 6c 20 62 65 |e number| will be|
|00000640| 20 65 78 61 63 74 6c 79 | 0d 77 68 65 72 65 20 74 | exactly|.where t|
|00000650| 68 65 20 65 72 72 6f 72 | 20 69 73 2c 20 6f 72 20 |he error| is, or |
|00000660| 61 74 20 6d 6f 73 74 20 | 61 20 63 6f 75 70 6c 65 |at most |a couple|
|00000670| 20 6f 66 20 6c 69 6e 65 | 73 20 61 66 74 65 72 20 | of line|s after |
|00000680| 74 68 65 20 72 65 61 6c | 20 6d 69 73 74 61 6b 65 |the real| mistake|
|00000690| 2e 0d 0d 4d 6f 73 74 20 | 73 79 6e 74 61 78 20 65 |...Most |syntax e|
|000006a0| 72 72 6f 72 73 20 77 69 | 6c 6c 20 62 65 20 65 61 |rrors wi|ll be ea|
|000006b0| 73 79 20 74 6f 20 73 70 | 6f 74 20 61 6e 64 20 66 |sy to sp|ot and f|
|000006c0| 69 78 d1 6d 69 73 73 69 | 6e 67 20 70 75 6e 63 74 |ix.missi|ng punct|
|000006d0| 75 61 74 69 6f 6e 20 73 | 75 63 68 0d 61 73 20 62 |uation s|uch.as b|
|000006e0| 72 61 63 6b 65 74 73 20 | 6f 72 20 71 75 6f 74 65 |rackets |or quote|
|000006f0| 73 20 66 6f 72 20 65 78 | 61 6d 70 6c 65 2e 20 4f |s for ex|ample. O|
|00000700| 6e 65 20 6f 64 64 62 61 | 6c 6c 20 65 72 72 6f 72 |ne oddba|ll error|
|00000710| 20 74 68 61 74 20 6d 61 | 79 20 62 65 20 64 69 66 | that ma|y be dif|
|00000720| 66 69 63 75 6c 74 20 74 | 6f 0d 64 69 61 67 6e 6f |ficult t|o.diagno|
|00000730| 73 65 20 69 73 20 74 68 | 65 20 69 6e 73 69 64 69 |se is th|e insidi|
|00000740| 6f 75 73 20 6d 69 73 73 | 69 6e 67 20 22 23 22 2c |ous miss|ing "#",|
|00000750| 20 61 73 20 69 6e 0d 09 | 23 24 43 61 6c 63 75 6c | as in..|#$Calcul|
|00000760| 61 74 65 3a 20 61 20 66 | 6f 75 72 20 66 75 6e 63 |ate: a f|our func|
|00000770| 74 69 6f 6e 20 63 61 6c | 75 6c 61 74 6f 72 2e 0d |tion cal|ulator..|
|00000780| 09 23 45 6e 74 65 72 20 | 65 78 70 72 65 73 73 69 |.#Enter |expressi|
|00000790| 6f 6e 73 20 75 73 69 6e | 67 20 6e 75 6d 62 65 72 |ons usin|g number|
|000007a0| 73 20 61 6e 64 20 2b 20 | 2d 20 2a 20 2f 2e 0d 09 |s and + |- * /...|
|000007b0| 23 49 66 20 74 68 65 20 | 65 78 70 72 65 73 73 69 |#If the |expressi|
|000007c0| 6f 6e 20 69 73 20 6e 6f | 74 20 70 72 6f 70 65 72 |on is no|t proper|
|000007d0| 6c 79 20 66 6f 72 6d 65 | 64 2c 20 61 73 20 69 6e |ly forme|d, as in|
|000007e0| 0d 09 20 32 20 2b 20 33 | 20 2a 20 2f 20 37 2e 35 |.. 2 + 3| * / 7.5|
|000007f0| 0d 09 20 23 74 68 65 6e | 20 79 6f 75 27 6c 6c 20 |.. #then| you'll |
|00000800| 67 65 74 20 61 6e 20 65 | 72 72 6f 72 20 6d 65 73 |get an e|rror mes|
|00000810| 73 61 67 65 2e 0d 09 23 | 2e 2e 2e 2e 0d d1 74 68 |sage...#|......th|
|00000820| 69 73 20 77 6f 75 6c 64 | 20 70 72 6f 64 75 63 65 |is would| produce|
|00000830| 20 74 68 65 20 65 72 72 | 6f 72 20 6d 65 73 73 61 | the err|or messa|
|00000840| 67 65 0d 09 68 41 57 4b | 3a 20 20 73 79 6e 74 61 |ge..hAWK|: synta|
|00000850| 78 20 65 72 72 6f 72 20 | 6e 65 61 72 20 6c 69 6e |x error |near lin|
|00000860| 65 20 34 3a 0d 09 20 32 | 20 2b 20 33 20 2a 20 2f |e 4:.. 2| + 3 * /|
|00000870| 20 37 2e 35 0d 09 09 09 | 20 09 20 20 5e 20 70 61 | 7.5....| . ^ pa|
|00000880| 72 73 65 20 65 72 72 6f | 72 0d 69 6e 20 24 74 65 |rse erro|r.in $te|
|00000890| 6d 70 53 74 64 45 72 72 | 2e 20 48 6f 77 65 76 65 |mpStdErr|. Howeve|
|000008a0| 72 2c 20 62 65 20 74 68 | 61 6e 6b 66 75 6c 20 69 |r, be th|ankful i|
|000008b0| 66 20 79 6f 75 20 47 45 | 54 20 61 20 6d 65 73 73 |f you GE|T a mess|
|000008c0| 61 67 65 20 63 6f 6d 70 | 6c 61 69 6e 69 6e 67 0d |age comp|laining.|
|000008d0| 61 62 6f 75 74 20 61 6e | 20 75 6e 63 6f 6d 6d 65 |about an| uncomme|
|000008e0| 6e 74 65 64 20 63 6f 6d | 6d 65 6e 74 2e 20 51 75 |nted com|ment. Qu|
|000008f0| 69 74 65 20 6f 66 74 65 | 6e 2c 20 79 6f 75 27 6c |ite ofte|n, you'l|
|00000900| 6c 20 67 65 74 20 6e 6f | 20 6d 65 73 73 61 67 65 |l get no| message|
|00000910| 20 61 74 0d 61 6c 6c d1 | 68 41 57 4b 20 77 69 6c | at.all.|hAWK wil|
|00000920| 6c 20 71 75 69 65 74 6c | 79 20 65 78 65 63 75 74 |l quietl|y execut|
|00000930| 65 20 74 68 65 20 63 6f | 6d 6d 65 6e 74 20 61 73 |e the co|mment as|
|00000940| 20 74 68 6f 75 67 68 20 | 69 74 20 77 65 72 65 20 | though |it were |
|00000950| 70 61 72 74 20 6f 66 20 | 79 6f 75 72 0d 70 72 6f |part of |your.pro|
|00000960| 67 72 61 6d 20 28 6d 6f | 72 65 20 6f 6e 20 74 68 |gram (mo|re on th|
|00000970| 69 73 20 62 65 6c 6f 77 | 20 2d 20 73 65 65 20 74 |is below| - see t|
|00000980| 68 65 20 73 74 61 72 74 | 20 6f 66 20 22 43 6f 6d |he start| of "Com|
|00000990| 6d 6f 6e 20 62 75 67 73 | 22 29 2e 0d 0d 55 73 69 |mon bugs|")...Usi|
|000009a0| 6e 67 20 61 20 68 41 57 | 4b 20 6b 65 79 20 77 6f |ng a hAW|K key wo|
|000009b0| 72 64 20 6f 72 20 62 75 | 69 6c 74 69 6e 20 66 75 |rd or bu|iltin fu|
|000009c0| 6e 63 74 69 6f 6e 20 6e | 61 6d 65 20 61 73 20 61 |nction n|ame as a|
|000009d0| 20 76 61 72 69 61 62 6c | 65 20 6e 61 6d 65 20 69 | variabl|e name i|
|000009e0| 73 20 61 6c 73 6f 20 61 | 0d 70 6f 70 75 6c 61 72 |s also a|.popular|
|000009f0| 20 65 72 72 6f 72 d1 77 | 61 74 63 68 20 6f 75 74 | error.w|atch out|
|00000a00| 20 65 73 70 65 63 69 61 | 6c 6c 79 20 66 6f 72 20 | especia|lly for |
|00000a10| 22 69 6e 22 20 61 6e 64 | 20 22 6c 65 6e 67 74 68 |"in" and| "length|
|00000a20| 22 2e 0d 0d 41 20 63 61 | 72 72 69 61 67 65 20 72 |"...A ca|rriage r|
|00000a30| 65 74 75 72 6e 20 6f 72 | 20 73 65 6d 69 63 6f 6c |eturn or| semicol|
|00000a40| 6f 6e 20 69 73 20 73 6f | 6d 65 74 69 6d 65 73 20 |on is so|metimes |
|00000a50| 72 65 71 75 69 72 65 64 | 20 69 6e 20 61 20 68 41 |required| in a hA|
|00000a60| 57 4b 20 73 74 61 74 65 | 6d 65 6e 74 0d 74 6f 20 |WK state|ment.to |
|00000a70| 64 69 73 61 6d 62 69 67 | 75 61 74 65 20 74 68 65 |disambig|uate the|
|00000a80| 20 73 79 6e 74 61 78 2e | 20 53 65 65 20 74 68 65 | syntax.| See the|
|00000a90| 20 22 47 72 6f 75 70 69 | 6e 67 20 61 6e 64 20 62 | "Groupi|ng and b|
|00000aa0| 72 65 61 6b 69 6e 67 20 | 6c 69 6e 65 73 22 20 73 |reaking |lines" s|
|00000ab0| 65 63 74 69 6f 6e 20 69 | 6e 0d 74 68 65 20 22 68 |ection i|n.the "h|
|00000ac0| 41 57 4b 20 70 72 6f 67 | 72 61 6d 20 73 74 72 75 |AWK prog|ram stru|
|00000ad0| 63 74 75 72 65 22 20 63 | 68 61 70 74 65 72 20 6f |cture" c|hapter o|
|00000ae0| 66 20 74 68 65 20 68 41 | 57 4b 20 55 73 65 72 27 |f the hA|WK User'|
|00000af0| 73 20 4d 61 6e 75 61 6c | 20 66 6f 72 20 74 68 65 |s Manual| for the|
|00000b00| 0d 64 65 74 61 69 6c 73 | 20 28 74 68 61 74 27 73 |.details| (that's|
|00000b10| 20 73 65 63 74 69 6f 6e | 20 49 20 32 20 69 6e 20 | section| I 2 in |
|00000b20| 74 68 65 20 70 6f 70 75 | 70 20 6d 61 72 6b 73 20 |the popu|p marks |
|00000b30| 6d 65 6e 75 20 66 6f 72 | 20 74 68 65 20 6d 61 6e |menu for| the man|
|00000b40| 75 61 6c 29 2e 0d 0d 49 | 66 20 79 6f 75 20 72 65 |ual)...I|f you re|
|00000b50| 61 6c 6c 79 20 67 65 74 | 20 73 74 75 63 6b 20 74 |ally get| stuck t|
|00000b60| 72 79 69 6e 67 20 74 6f | 20 64 69 61 67 6e 6f 73 |rying to| diagnos|
|00000b70| 65 20 61 20 73 79 6e 74 | 61 78 20 65 72 72 6f 72 |e a synt|ax error|
|00000b80| 2c 20 74 72 79 20 6c 6f | 6f 6b 69 6e 67 20 74 68 |, try lo|oking th|
|00000b90| 72 6f 75 67 68 0d 74 68 | 65 20 73 61 6d 70 6c 65 |rough.th|e sample|
|00000ba0| 20 70 72 6f 67 72 61 6d | 73 20 73 75 70 70 6c 69 | program|s suppli|
|00000bb0| 65 64 20 77 69 74 68 20 | 68 41 57 4b 20 66 6f 72 |ed with |hAWK for|
|00000bc0| 20 73 69 6d 69 6c 61 72 | 20 63 6f 6e 73 74 72 75 | similar| constru|
|00000bd0| 63 74 69 6f 6e 73 2c 20 | 61 73 20 77 65 6c 6c 0d |ctions, |as well.|
|00000be0| 61 73 20 72 65 72 65 61 | 64 69 6e 67 20 74 68 65 |as rerea|ding the|
|00000bf0| 20 72 65 6c 65 76 61 6e | 74 20 6d 61 6e 75 61 6c | relevan|t manual|
|00000c00| 20 73 65 63 74 69 6f 6e | 73 2e 20 53 65 65 20 61 | section|s. See a|
|00000c10| 6c 73 6f 20 74 68 65 20 | 22 43 6f 6d 6d 6f 6e 20 |lso the |"Common |
|00000c20| 62 75 67 73 22 20 73 65 | 63 74 69 6f 6e 0d 62 65 |bugs" se|ction.be|
|00000c30| 6c 6f 77 2e 0d 0d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |low...--|--------|
|00000c40| 2d 2d 2d 2d 2d 2d 2d 2d | 0d 49 74 20 64 6f 65 73 |--------|.It does|
|00000c50| 6e 27 74 20 64 6f 20 77 | 68 61 74 20 49 20 77 61 |n't do w|hat I wa|
|00000c60| 6e 74 65 64 0d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |nted.---|--------|
|00000c70| 2d 2d 2d 2d 2d 2d 2d 0d | 09 50 72 6f 6f 66 72 65 |-------.|.Proofre|
|00000c80| 61 64 69 6e 67 20 68 65 | 6c 70 70 73 0d 68 41 57 |ading he|lpps.hAW|
|00000c90| 4b 20 70 72 6f 67 72 61 | 6d 73 20 61 72 65 20 73 |K progra|ms are s|
|00000ca0| 6f 20 65 61 73 79 20 74 | 6f 20 77 72 69 74 65 20 |o easy t|o write |
|00000cb0| 74 68 61 74 20 74 68 65 | 72 65 20 69 73 20 61 20 |that the|re is a |
|00000cc0| 73 74 72 6f 6e 67 20 74 | 65 6d 70 74 61 74 69 6f |strong t|emptatio|
|00000cd0| 6e 20 74 6f 0d 72 75 73 | 68 2e 20 54 68 65 20 66 |n to.rus|h. The f|
|00000ce0| 69 78 20 66 6f 72 20 6d | 6f 73 74 20 6f 66 20 74 |ix for m|ost of t|
|00000cf0| 68 65 73 65 20 70 72 6f | 62 6c 65 6d 73 20 69 73 |hese pro|blems is|
|00000d00| 20 74 6f 20 63 61 72 65 | 66 75 6c 6c 79 20 72 65 | to care|fully re|
|00000d10| 61 64 20 74 68 72 6f 75 | 67 68 20 79 6f 75 72 0d |ad throu|gh your.|
|00000d20| 6e 65 77 20 63 6f 64 65 | 20 6f 6e 63 65 20 62 65 |new code| once be|
|00000d30| 66 6f 72 65 20 72 75 6e | 6e 69 6e 67 20 69 74 2e |fore run|ning it.|
|00000d40| 20 48 6f 77 65 76 65 72 | 2c 20 77 65 27 72 65 20 | However|, we're |
|00000d50| 6f 6e 6c 79 20 68 75 6d | 61 6e 2e 2e 2e 2e 0d 0d |only hum|an......|
|00000d60| 09 50 72 69 6e 74 20 70 | 6f 77 65 72 0d 54 68 65 |.Print p|ower.The|
|00000d70| 20 62 65 73 74 20 77 61 | 79 20 74 6f 20 64 69 61 | best wa|y to dia|
|00000d80| 67 6e 6f 73 65 20 61 20 | 62 75 67 20 69 6e 20 61 |gnose a |bug in a|
|00000d90| 20 70 72 6f 67 72 61 6d | 20 69 73 20 74 6f 20 67 | program| is to g|
|00000da0| 65 74 20 79 6f 75 72 20 | 70 72 6f 67 72 61 6d 20 |et your |program |
|00000db0| 74 6f 20 74 61 6c 6b 20 | 74 6f 0d 79 6f 75 20 61 |to talk |to.you a|
|00000dc0| 62 6f 75 74 20 77 68 61 | 74 20 69 74 20 69 73 20 |bout wha|t it is |
|00000dd0| 64 6f 69 6e 67 2e 20 59 | 6f 75 72 20 6d 6f 73 74 |doing. Y|our most|
|00000de0| 20 70 6f 77 65 72 66 75 | 6c 20 64 65 62 75 67 67 | powerfu|l debugg|
|00000df0| 69 6e 67 20 61 69 64 20 | 69 73 20 62 75 69 6c 74 |ing aid |is built|
|00000e00| 20 69 6e 20 74 6f 0d 68 | 41 57 4b 2c 20 61 6e 64 | in to.h|AWK, and|
|00000e10| 20 67 6f 65 73 20 62 79 | 20 74 68 65 20 6e 61 6d | goes by| the nam|
|00000e20| 65 20 6f 66 20 22 70 72 | 69 6e 74 22 2e 20 54 68 |e of "pr|int". Th|
|00000e30| 65 20 66 69 72 73 74 20 | 72 75 6c 65 20 6f 66 20 |e first |rule of |
|00000e40| 68 41 57 4b 20 64 65 62 | 75 67 67 69 6e 67 20 69 |hAWK deb|ugging i|
|00000e50| 73 2c 0d 50 72 69 6e 74 | 20 4f 75 74 20 57 68 61 |s,.Print| Out Wha|
|00000e60| 74 27 73 20 52 65 61 6c | 6c 79 20 47 6f 69 6e 67 |t's Real|ly Going|
|00000e70| 20 4f 6e 2e 20 4d 61 6e | 79 20 6f 66 20 74 68 65 | On. Man|y of the|
|00000e80| 20 73 75 67 67 65 73 74 | 69 6f 6e 73 20 62 65 6c | suggest|ions bel|
|00000e90| 6f 77 20 64 65 61 6c 20 | 77 69 74 68 0d 70 72 69 |ow deal |with.pri|
|00000ea0| 6e 74 69 6e 67 20 6f 75 | 74 20 64 69 61 67 6e 6f |nting ou|t diagno|
|00000eb0| 73 74 69 63 73 2e 0d 0d | 09 4d 61 6b 65 20 61 20 |stics...|.Make a |
|00000ec0| 63 6f 70 79 0d 49 66 20 | 79 6f 75 27 72 65 20 64 |copy.If |you're d|
|00000ed0| 65 62 75 67 67 69 6e 67 | 20 61 6e 20 61 6d 69 62 |ebugging| an amib|
|00000ee0| 69 74 69 6f 75 73 20 70 | 72 6f 67 72 61 6d 2c 20 |itious p|rogram, |
|00000ef0| 6d 61 6b 65 20 61 20 63 | 6f 70 79 20 6f 66 20 69 |make a c|opy of i|
|00000f00| 74 20 61 6e 64 20 64 65 | 62 75 67 20 74 68 65 0d |t and de|bug the.|
|00000f10| 63 6f 70 79 2e 20 42 79 | 20 73 70 69 6e 6e 69 6e |copy. By| spinnin|
|00000f20| 67 20 6f 66 66 20 6f 6e | 65 20 6f 72 20 6d 6f 72 |g off on|e or mor|
|00000f30| 65 20 76 65 72 73 69 6f | 6e 73 20 6f 66 20 79 6f |e versio|ns of yo|
|00000f40| 75 72 20 70 72 6f 67 72 | 61 6d 2c 79 6f 75 27 6c |ur progr|am,you'l|
|00000f50| 6c 20 62 65 20 61 62 6c | 65 20 74 6f 0d 62 61 63 |l be abl|e to.bac|
|00000f60| 6b 20 75 70 20 69 66 20 | 79 6f 75 20 61 6e 67 72 |k up if |you angr|
|00000f70| 69 6c 79 20 64 65 6c 65 | 74 65 20 61 20 73 74 75 |ily dele|te a stu|
|00000f80| 70 69 64 20 63 68 75 6e | 6b 20 6f 66 20 63 6f 64 |pid chun|k of cod|
|00000f90| 65 2c 20 6f 6e 6c 79 20 | 74 6f 20 72 65 61 6c 69 |e, only |to reali|
|00000fa0| 73 65 20 6c 61 74 65 72 | 20 74 68 61 74 0d 69 74 |se later| that.it|
|00000fb0| 20 77 61 73 20 69 6e 73 | 70 69 72 65 64 20 61 6e | was ins|pired an|
|00000fc0| 64 20 70 65 72 66 65 63 | 74 6c 79 20 63 6f 72 72 |d perfec|tly corr|
|00000fd0| 65 63 74 2e 0d 0d 09 54 | 72 61 63 6b 20 79 6f 75 |ect....T|rack you|
|00000fe0| 72 20 63 68 61 6e 67 65 | 73 0d 49 6e 20 61 20 74 |r change|s.In a t|
|00000ff0| 79 70 69 63 61 6c 20 64 | 65 62 75 67 67 69 6e 67 |ypical d|ebugging|
|00001000| 20 73 65 73 73 69 6f 6e | 20 79 6f 75 20 77 69 6c | session| you wil|
|00001010| 6c 20 62 65 20 69 6e 73 | 65 72 74 69 6e 67 20 6e |l be ins|erting n|
|00001020| 65 77 20 73 74 61 74 65 | 6d 65 6e 74 73 20 6f 6e |ew state|ments on|
|00001030| 20 61 20 74 72 69 61 6c | 0d 6f 72 20 74 65 6d 70 | a trial|.or temp|
|00001040| 6f 72 61 72 79 20 62 61 | 73 69 73 2c 20 61 6e 64 |orary ba|sis, and|
|00001050| 20 61 6c 73 6f 20 64 65 | 6c 65 74 69 6e 67 20 6f | also de|leting o|
|00001060| 6c 64 20 73 74 61 74 65 | 6d 65 6e 74 73 2e 20 49 |ld state|ments. I|
|00001070| 74 20 63 61 6e 20 62 65 | 20 64 69 66 66 69 63 75 |t can be| difficu|
|00001080| 6c 74 20 74 6f 0d 62 61 | 63 6b 20 75 70 2c 20 61 |lt to.ba|ck up, a|
|00001090| 6e 64 20 65 61 73 79 20 | 74 6f 20 67 65 74 20 6c |nd easy |to get l|
|000010a0| 6f 73 74 20 69 6e 20 61 | 20 6b 6e 6f 74 20 6f 66 |ost in a| knot of|
|000010b0| 20 63 6f 6e 64 69 74 69 | 6f 6e 61 6c 20 74 72 69 | conditi|onal tri|
|000010c0| 61 6c 73 2c 20 73 6f 20 | 74 68 65 20 73 65 63 6f |als, so |the seco|
|000010d0| 6e 64 20 72 75 6c 65 0d | 6f 66 20 68 41 57 4b 20 |nd rule.|of hAWK |
|000010e0| 64 65 62 75 67 67 69 6e | 67 20 69 73 20 4d 61 72 |debuggin|g is Mar|
|000010f0| 6b 20 59 6f 75 72 20 43 | 68 61 6e 67 65 73 2e 20 |k Your C|hanges. |
|00001100| 54 6f 20 74 65 6d 70 6f | 72 61 72 69 6c 79 20 63 |To tempo|rarily c|
|00001110| 6f 6d 6d 65 6e 74 20 6f | 75 74 20 61 0d 73 74 61 |omment o|ut a.sta|
|00001120| 74 65 6d 65 6e 74 2c 20 | 70 6c 61 63 65 20 22 23 |tement, |place "#|
|00001130| 23 22 20 69 6e 20 66 72 | 6f 6e 74 20 6f 66 20 69 |#" in fr|ont of i|
|00001140| 74 2c 20 72 61 74 68 65 | 72 20 74 68 61 6e 20 61 |t, rathe|r than a|
|00001150| 20 73 69 6e 67 6c 65 20 | 22 23 22 2e 20 49 66 20 | single |"#". If |
|00001160| 61 20 6e 65 77 0d 73 74 | 61 74 65 6d 65 6e 74 20 |a new.st|atement |
|00001170| 6d 61 79 20 6e 6f 74 20 | 62 65 20 70 65 72 6d 61 |may not |be perma|
|00001180| 6e 65 6e 74 2c 20 70 6c | 61 63 65 20 22 23 23 23 |nent, pl|ace "###|
|00001190| 22 20 61 66 74 65 72 20 | 69 74 2e 20 4c 61 74 65 |" after |it. Late|
|000011a0| 72 2c 20 79 6f 75 20 63 | 61 6e 0d 73 65 61 72 63 |r, you c|an.searc|
|000011b0| 68 20 66 6f 72 20 79 6f | 75 72 20 63 68 61 6e 67 |h for yo|ur chang|
|000011c0| 65 73 20 62 79 20 6c 6f | 6f 6b 69 6e 67 20 66 6f |es by lo|oking fo|
|000011d0| 72 20 22 23 23 22 20 61 | 6e 64 20 22 23 23 23 22 |r "##" a|nd "###"|
|000011e0| 2e 20 41 6e 79 20 76 61 | 72 69 61 74 69 6f 6e 20 |. Any va|riation |
|000011f0| 6f 6e 0d 74 68 69 73 20 | 73 75 63 68 20 61 73 20 |on.this |such as |
|00001200| 22 23 40 22 20 69 73 20 | 70 65 72 66 65 63 74 6c |"#@" is |perfectl|
|00001210| 79 20 66 69 6e 65 3b 20 | 74 68 65 20 67 6f 61 6c |y fine; |the goal|
|00001220| 20 69 73 20 74 6f 20 62 | 65 20 61 62 6c 65 20 74 | is to b|e able t|
|00001230| 6f 20 73 70 6f 74 20 61 | 6c 6c 20 6f 66 20 79 6f |o spot a|ll of yo|
|00001240| 75 72 0d 63 68 61 6e 67 | 65 73 20 61 74 20 61 6e |ur.chang|es at an|
|00001250| 79 20 74 69 6d 65 20 62 | 79 20 75 73 69 6e 67 20 |y time b|y using |
|00001260| 79 6f 75 72 20 22 53 65 | 61 72 63 68 22 20 63 6f |your "Se|arch" co|
|00001270| 6d 6d 61 6e 64 20 69 6e | 20 79 6f 75 72 20 65 64 |mmand in| your ed|
|00001280| 69 74 6f 72 2e 20 0d 0d | 59 6f 75 20 63 61 6e 20 |itor. ..|You can |
|00001290| 65 76 65 6e 20 73 65 70 | 61 72 61 74 65 20 6f 75 |even sep|arate ou|
|000012a0| 74 20 63 6f 6e 6e 65 63 | 74 65 64 20 63 68 61 6e |t connec|ted chan|
|000012b0| 67 65 73 20 62 79 20 74 | 61 67 67 69 6e 67 20 74 |ges by t|agging t|
|000012c0| 68 65 20 61 66 66 65 63 | 74 65 64 20 6c 69 6e 65 |he affec|ted line|
|000012d0| 73 20 77 69 74 68 0d 22 | 23 23 31 22 20 66 6f 72 |s with."|##1" for|
|000012e0| 20 6f 6e 65 20 67 72 6f | 75 70 2c 20 22 23 23 32 | one gro|up, "##2|
|000012f0| 22 20 66 6f 72 20 61 6e | 6f 74 68 65 72 20 28 74 |" for an|other (t|
|00001300| 68 65 20 74 61 67 20 67 | 6f 65 73 20 61 74 20 74 |he tag g|oes at t|
|00001310| 68 65 20 62 65 67 69 6e | 6e 69 6e 67 20 6f 66 20 |he begin|ning of |
|00001320| 61 0d 6c 69 6e 65 20 66 | 6f 72 20 61 20 64 65 6c |a.line f|or a del|
|00001330| 65 74 65 2c 20 61 74 20 | 74 68 65 20 65 6e 64 20 |ete, at |the end |
|00001340| 6f 66 20 74 68 65 20 6c | 69 6e 65 20 66 6f 72 20 |of the l|ine for |
|00001350| 61 20 6e 65 77 6c 79 2d | 61 64 64 65 64 20 73 74 |a newly-|added st|
|00001360| 61 74 65 6d 65 6e 74 29 | 2e 20 42 75 74 0d 74 68 |atement)|. But.th|
|00001370| 69 73 20 69 73 20 67 65 | 74 74 69 6e 67 20 61 20 |is is ge|tting a |
|00001380| 62 69 74 20 63 6f 6d 70 | 6c 69 63 61 74 65 64 2c |bit comp|licated,|
|00001390| 20 73 6f 20 64 6f 20 69 | 74 20 6f 6e 6c 79 20 61 | so do i|t only a|
|000013a0| 73 20 61 20 6c 61 73 74 | 20 72 65 73 6f 72 74 2e |s a last| resort.|
|000013b0| 0d 0d 09 56 61 72 69 61 | 62 6c 65 20 76 61 6c 75 |...Varia|ble valu|
|000013c0| 65 73 0d 54 6f 20 63 68 | 65 63 6b 20 74 68 65 20 |es.To ch|eck the |
|000013d0| 76 61 6c 75 65 20 6f 66 | 20 61 20 76 61 72 69 61 |value of| a varia|
|000013e0| 62 6c 65 20 28 73 61 79 | 20 78 31 29 2c 20 79 6f |ble (say| x1), yo|
|000013f0| 75 20 6d 69 67 68 74 20 | 61 73 20 77 65 6c 6c 20 |u might |as well |
|00001400| 6b 65 65 70 20 69 74 20 | 73 69 6d 70 6c 65 3a 0d |keep it |simple:.|
|00001410| 09 70 72 69 6e 74 20 78 | 31 20 23 23 23 0d 77 69 |.print x|1 ###.wi|
|00001420| 6c 6c 20 64 6f 20 74 68 | 65 20 6a 6f 62 2e 20 49 |ll do th|e job. I|
|00001430| 66 20 79 6f 75 20 61 72 | 65 20 63 68 65 63 6b 69 |f you ar|e checki|
|00001440| 6e 67 20 6d 61 6e 79 20 | 76 61 72 69 61 62 6c 65 |ng many |variable|
|00001450| 73 2c 20 73 6f 6d 65 74 | 68 69 6e 67 20 6c 69 6b |s, somet|hing lik|
|00001460| 65 0d 09 70 72 69 6e 74 | 20 22 78 31 20 3d 22 2c |e..print| "x1 =",|
|00001470| 20 78 31 2c 20 22 61 74 | 20 6c 69 6e 65 20 34 33 | x1, "at| line 43|
|00001480| 22 20 23 23 23 0d 6d 61 | 79 20 62 65 20 63 61 6c |" ###.ma|y be cal|
|00001490| 6c 65 64 20 66 6f 72 2e | 0d 0d 09 56 61 72 69 61 |led for.|...Varia|
|000014a0| 62 6c 65 20 6e 61 6d 65 | 73 0d 54 68 65 72 65 20 |ble name|s.There |
|000014b0| 69 73 20 6e 6f 20 73 75 | 63 68 20 74 68 69 6e 67 |is no su|ch thing|
|000014c0| 20 61 73 20 61 6e 20 75 | 6e 64 65 63 6c 61 72 65 | as an u|ndeclare|
|000014d0| 64 20 76 61 72 69 61 62 | 6c 65 20 69 6e 20 68 41 |d variab|le in hA|
|000014e0| 57 4b 2e 20 54 68 69 73 | 20 63 6f 6e 76 65 6e 69 |WK. This| conveni|
|000014f0| 65 6e 63 65 0d 63 61 6e | 20 74 72 69 70 20 79 6f |ence.can| trip yo|
|00001500| 75 20 75 70 2c 20 68 6f | 77 65 76 65 72 2c 20 69 |u up, ho|wever, i|
|00001510| 66 20 79 6f 75 20 61 63 | 63 69 64 65 6e 74 61 6c |f you ac|cidental|
|00001520| 6c 79 20 6d 69 73 73 70 | 65 6c 6c 20 74 68 65 20 |ly missp|ell the |
|00001530| 6e 61 6d 65 20 6f 66 20 | 61 0d 76 61 72 69 61 62 |name of |a.variab|
|00001540| 6c 65 2e 20 54 68 65 72 | 65 20 77 69 6c 6c 20 62 |le. Ther|e will b|
|00001550| 65 20 6e 6f 20 73 79 6e | 74 61 78 20 65 72 72 6f |e no syn|tax erro|
|00001560| 72 3b 20 74 68 65 20 6d | 69 73 73 70 65 6c 6c 65 |r; the m|isspelle|
|00001570| 64 20 6e 61 6d 65 20 77 | 69 6c 6c 20 6a 75 73 74 |d name w|ill just|
|00001580| 20 62 65 0d 74 72 65 61 | 74 65 64 20 61 73 20 61 | be.trea|ted as a|
|00001590| 20 64 69 66 66 65 72 65 | 6e 74 20 76 61 72 69 61 | differe|nt varia|
|000015a0| 62 6c 65 2e 20 49 66 20 | 79 6f 75 20 73 75 73 70 |ble. If |you susp|
|000015b0| 65 63 74 20 61 20 73 70 | 65 6c 6c 69 6e 67 20 65 |ect a sp|elling e|
|000015c0| 72 72 6f 72 20 69 73 20 | 74 68 65 20 63 75 6c 70 |rror is |the culp|
|000015d0| 72 69 74 0d 62 75 74 20 | 63 61 6e 27 74 20 73 70 |rit.but |can't sp|
|000015e0| 6f 74 20 69 74 2c 20 72 | 75 6e 20 24 57 6f 72 64 |ot it, r|un $Word|
|000015f0| 46 72 65 71 75 65 6e 63 | 79 20 75 73 69 6e 67 20 |Frequenc|y using |
|00001600| 79 6f 75 72 20 70 72 6f | 62 6c 65 6d 20 70 72 6f |your pro|blem pro|
|00001610| 67 72 61 6d 20 61 73 20 | 74 68 65 0d 69 6e 70 75 |gram as |the.inpu|
|00001620| 74 2e 20 54 68 69 73 20 | 77 69 6c 6c 20 70 72 6f |t. This |will pro|
|00001630| 64 75 63 65 20 61 20 6c | 69 73 74 20 6f 66 20 61 |duce a l|ist of a|
|00001640| 6c 6c 20 77 6f 72 64 73 | 20 69 6e 20 79 6f 75 72 |ll words| in your|
|00001650| 20 70 72 6f 67 72 61 6d | 2c 20 6d 61 6b 69 6e 67 | program|, making|
|00001660| 20 69 74 20 65 61 73 69 | 65 72 0d 74 6f 20 70 69 | it easi|er.to pi|
|00001670| 63 6b 20 6f 75 74 20 77 | 72 6f 6e 67 20 73 70 65 |ck out w|rong spe|
|00001680| 6c 6c 69 6e 67 73 2e 0d | 0d 4e 6f 74 65 20 74 6f |llings..|.Note to|
|00001690| 20 68 61 76 65 20 24 57 | 6f 72 64 46 72 65 71 75 | have $W|ordFrequ|
|000016a0| 65 6e 63 79 20 73 6b 69 | 70 20 6f 76 65 72 20 63 |ency ski|p over c|
|000016b0| 6f 6d 6d 65 6e 74 73 2c | 20 79 6f 75 20 63 61 6e |omments,| you can|
|000016c0| 20 75 6e 63 6f 6d 6d 65 | 6e 74 20 0d 09 23 23 2f | uncomme|nt ..##/|
|000016d0| 5e 23 2f 20 7b 6e 65 78 | 74 7d 20 23 73 6b 69 70 |^#/ {nex|t} #skip|
|000016e0| 20 6c 69 6e 65 73 20 63 | 6f 6e 74 61 69 6e 69 6e | lines c|ontainin|
|000016f0| 67 20 68 41 57 4b 20 63 | 6f 6d 6d 65 6e 74 73 0d |g hAWK c|omments.|
|00001700| 6a 75 73 74 20 61 66 74 | 65 72 20 74 68 65 20 22 |just aft|er the "|
|00001710| 42 45 47 49 4e 22 20 62 | 6c 6f 63 6b 20 69 6e 20 |BEGIN" b|lock in |
|00001720| 69 74 2e 0d 0d 09 41 73 | 73 65 72 74 69 6f 6e 73 |it....As|sertions|
|00001730| 0d 41 73 73 65 72 74 69 | 6f 6e 73 20 61 72 65 20 |.Asserti|ons are |
|00001740| 65 61 73 69 6c 79 20 63 | 68 65 63 6b 65 64 20 62 |easily c|hecked b|
|00001750| 79 20 61 64 64 69 6e 67 | 20 61 6e 20 22 61 73 73 |y adding| an "ass|
|00001760| 65 72 74 22 20 66 75 6e | 63 74 69 6f 6e 3a 0d 09 |ert" fun|ction:..|
|00001770| 66 75 6e 63 74 69 6f 6e | 20 61 73 73 65 72 74 28 |function| assert(|
|00001780| 65 78 70 72 2c 20 6d 65 | 73 73 61 67 65 2c 20 6c |expr, me|ssage, l|
|00001790| 69 6e 65 29 0d 09 09 7b | 0d 09 09 69 66 20 28 21 |ine)...{|...if (!|
|000017a0| 65 78 70 72 29 0d 09 09 | 09 70 72 69 6e 74 20 22 |expr)...|.print "|
|000017b0| 41 73 73 65 72 74 69 6f | 6e 20 66 6c 75 6e 6b 65 |Assertio|n flunke|
|000017c0| 64 3a 22 2c 20 6d 65 73 | 73 61 67 65 2c 20 22 61 |d:", mes|sage, "a|
|000017d0| 74 22 2c 20 6c 69 6e 65 | 0d 09 09 7d 0d 77 69 74 |t", line|...}.wit|
|000017e0| 68 20 75 73 61 67 65 20 | 73 75 63 68 20 61 73 0d |h usage |such as.|
|000017f0| 09 61 73 73 65 72 74 28 | 78 31 20 3c 3d 20 35 30 |.assert(|x1 <= 50|
|00001800| 2c 20 22 78 31 20 3c 3d | 20 35 30 22 2c 20 34 33 |, "x1 <=| 50", 43|
|00001810| 29 20 23 23 23 0d 2d 2d | 6e 6f 74 65 20 74 68 61 |) ###.--|note tha|
|00001820| 74 20 74 68 69 73 20 73 | 74 69 6c 6c 20 70 72 69 |t this s|till pri|
|00001830| 6e 74 73 20 70 72 6f 70 | 65 72 6c 79 20 69 66 20 |nts prop|erly if |
|00001840| 79 6f 75 20 6c 65 61 76 | 65 20 6f 75 74 20 74 68 |you leav|e out th|
|00001850| 65 20 6c 69 6e 65 0d 6e | 75 6d 62 65 72 20 61 73 |e line.n|umber as|
|00001860| 20 69 6e 20 61 73 73 65 | 72 74 28 78 31 20 3c 3d | in asse|rt(x1 <=|
|00001870| 20 35 30 2c 20 22 78 31 | 20 3c 3d 20 35 30 22 29 | 50, "x1| <= 50")|
|00001880| 20 2d 20 79 6f 75 20 6a | 75 73 74 20 77 6f 6e 27 | - you j|ust won'|
|00001890| 74 20 0d 67 65 74 20 74 | 68 65 20 6c 69 6e 65 20 |t .get t|he line |
|000018a0| 6e 75 6d 62 65 72 20 77 | 68 65 72 65 20 74 68 65 |number w|here the|
|000018b0| 20 70 72 6f 62 6c 65 6d | 20 6f 63 63 75 72 72 65 | problem| occurre|
|000018c0| 64 2e 0d 0d 09 41 73 73 | 65 72 74 69 6f 6e 73 20 |d....Ass|ertions |
|000018d0| 74 68 65 20 65 61 73 79 | 20 77 61 79 0d 46 6f 72 |the easy| way.For|
|000018e0| 20 74 68 65 20 74 72 75 | 6c 79 20 6c 61 7a 79 2c | the tru|ly lazy,|
|000018f0| 20 79 6f 75 20 63 6f 75 | 6c 64 20 70 75 74 20 79 | you cou|ld put y|
|00001900| 6f 75 72 20 61 73 73 65 | 72 74 69 6f 6e 73 20 69 |our asse|rtions i|
|00001910| 6e 20 75 73 69 6e 67 20 | 61 6e 0d 61 62 62 72 65 |n using |an.abbre|
|00001920| 76 69 61 74 65 64 20 66 | 6f 72 6d 2c 20 73 75 63 |viated f|orm, suc|
|00001930| 68 20 61 73 0d 09 61 28 | 78 31 20 3c 3d 20 35 30 |h as..a(|x1 <= 50|
|00001940| 29 2e 2e 2e 0d 09 61 28 | 6d 61 78 20 3e 20 30 20 |).....a(|max > 0 |
|00001950| 26 26 20 6d 61 78 20 3c | 20 31 30 30 30 29 20 65 |&& max <| 1000) e|
|00001960| 74 63 0d 61 6e 64 20 74 | 68 65 6e 20 72 75 6e 20 |tc.and t|hen run |
|00001970| 74 68 69 73 20 6c 69 74 | 74 6c 65 20 68 41 57 4b |this lit|tle hAWK|
|00001980| 20 70 72 6f 67 72 61 6d | 2c 20 77 68 69 63 68 20 | program|, which |
|00001990| 69 73 20 69 6e 20 79 6f | 75 72 20 22 68 41 57 4b |is in yo|ur "hAWK|
|000019a0| 0d 70 72 6f 67 72 61 6d | 73 22 20 66 6f 6c 64 65 |.program|s" folde|
|000019b0| 72 2c 20 6f 6e 20 79 6f | 75 72 20 70 72 6f 62 6c |r, on yo|ur probl|
|000019c0| 65 6d 20 70 72 6f 67 72 | 61 6d 20 74 6f 20 66 69 |em progr|am to fi|
|000019d0| 6c 6c 20 6f 75 74 20 74 | 68 65 0d 61 73 73 65 72 |ll out t|he.asser|
|000019e0| 74 69 6f 6e 73 20 28 6e | 6f 74 65 20 69 74 27 73 |tions (n|ote it's|
|000019f0| 20 62 65 65 6e 20 64 65 | 62 75 67 67 65 64 29 3a | been de|bugged):|
|00001a00| 0d 0d 23 20 24 45 78 70 | 61 6e 64 41 73 73 65 72 |..# $Exp|andAsser|
|00001a10| 74 69 6f 6e 73 20 3a 20 | 73 65 65 20 22 44 65 62 |tions : |see "Deb|
|00001a20| 75 67 67 69 6e 67 20 68 | 41 57 4b 20 70 72 6f 67 |ugging h|AWK prog|
|00001a30| 72 61 6d 73 22 0d 23 20 | 28 74 68 65 20 74 72 69 |rams".# |(the tri|
|00001a40| 63 6b 79 20 62 69 74 73 | 20 2d 20 74 72 65 61 74 |cky bits| - treat|
|00001a50| 20 71 75 6f 74 65 73 20 | 70 72 6f 70 65 72 6c 79 | quotes |properly|
|00001a60| 2c 20 61 6e 64 0d 23 20 | 61 76 6f 69 64 20 75 73 |, and.# |avoid us|
|00001a70| 69 6e 67 20 73 75 62 28 | 29 2c 20 73 69 6e 63 65 |ing sub(|), since|
|00001a80| 20 74 68 65 20 72 65 70 | 6c 61 63 65 6d 65 6e 74 | the rep|lacement|
|00001a90| 20 73 74 72 69 6e 67 20 | 6d 69 67 68 74 20 63 6f | string |might co|
|00001aa0| 6e 74 61 69 6e 0d 23 20 | 61 20 22 26 22 20 77 68 |ntain.# |a "&" wh|
|00001ab0| 69 63 68 20 73 74 61 6e | 64 73 20 66 6f 72 20 22 |ich stan|ds for "|
|00001ac0| 65 76 65 72 79 74 68 69 | 6e 67 20 74 68 61 74 20 |everythi|ng that |
|00001ad0| 77 61 73 20 6d 61 74 63 | 68 65 64 22 2e 29 0d 23 |was matc|hed".).#|
|00001ae0| 0d 23 20 50 61 73 73 20 | 69 74 20 79 6f 75 72 20 |.# Pass |it your |
|00001af0| 70 72 6f 62 6c 65 6d 20 | 70 72 6f 67 72 61 6d 20 |problem |program |
|00001b00| 61 73 20 74 68 65 20 73 | 69 6e 67 6c 65 20 69 6e |as the s|ingle in|
|00001b10| 70 75 74 20 66 69 6c 65 | 3a 0d 23 20 6f 76 65 72 |put file|:.# over|
|00001b20| 77 72 69 74 65 73 20 74 | 68 65 20 66 69 6c 65 2c |writes t|he file,|
|00001b30| 20 72 65 70 6c 61 63 69 | 6e 67 20 09 09 61 28 61 | replaci|ng ..a(a|
|00001b40| 73 73 65 72 74 69 6f 6e | 29 20 09 09 20 77 69 74 |ssertion|) .. wit|
|00001b50| 68 0d 23 20 09 09 61 73 | 73 65 72 74 28 61 73 73 |h.# ..as|sert(ass|
|00001b60| 65 72 74 69 6f 6e 2c 20 | 22 61 73 73 65 72 74 69 |ertion, |"asserti|
|00001b70| 6f 6e 22 2c 20 6c 69 6e | 65 20 6e 75 6d 62 65 72 |on", lin|e number|
|00001b80| 29 20 23 23 23 0d 46 4e | 52 20 3d 3d 20 31 20 7b |) ###.FN|R == 1 {|
|00001b90| 6f 75 74 66 69 6c 65 20 | 3d 20 46 49 4c 45 4e 41 |outfile |= FILENA|
|00001ba0| 4d 45 7d 0d 20 7b 09 69 | 66 20 28 6d 61 74 63 68 |ME}. {.i|f (match|
|00001bb0| 28 24 30 2c 20 2f 5b 20 | 5c 74 5d 2a 61 5c 28 28 |($0, /[ |\t]*a\((|
|00001bc0| 2e 2b 29 5c 29 2f 29 29 | 0d 09 09 7b 0d 09 09 6d |.+)\)/))|...{...m|
|00001bd0| 61 74 63 68 28 24 30 2c | 20 2f 5c 28 28 2e 2b 29 |atch($0,| /\((.+)|
|00001be0| 5c 29 2f 29 20 23 66 69 | 6e 64 20 74 68 65 20 61 |\)/) #fi|nd the a|
|00001bf0| 72 67 75 6d 65 6e 74 20 | 70 72 6f 70 65 72 0d 09 |rgument |proper..|
|00001c00| 09 66 69 72 73 74 20 3d | 20 73 75 62 73 74 72 28 |.first =| substr(|
|00001c10| 24 30 2c 20 52 53 54 41 | 52 54 2b 31 2c 20 52 4c |$0, RSTA|RT+1, RL|
|00001c20| 45 4e 47 54 48 2d 32 29 | 20 23 63 6f 70 79 20 69 |ENGTH-2)| #copy i|
|00001c30| 74 0d 09 09 73 65 63 6f | 6e 64 20 3d 20 66 69 72 |t...seco|nd = fir|
|00001c40| 73 74 0d 09 09 67 73 75 | 62 28 2f 22 2f 2c 20 22 |st...gsu|b(/"/, "|
|00001c50| 5c 5c 5c 22 22 2c 20 73 | 65 63 6f 6e 64 29 20 23 |\\\"", s|econd) #|
|00001c60| 65 73 63 61 70 65 20 71 | 75 6f 74 65 73 0d 09 09 |escape q|uotes...|
|00001c70| 6d 61 74 63 68 28 24 30 | 2c 20 2f 5b 20 5c 74 5d |match($0|, /[ \t]|
|00001c80| 2a 2f 29 20 23 6d 61 74 | 63 68 20 73 74 61 72 74 |*/) #mat|ch start|
|00001c90| 69 6e 67 20 77 68 69 74 | 65 20 73 70 61 63 65 0d |ing whit|e space.|
|00001ca0| 09 09 73 74 61 72 74 65 | 72 20 3d 20 73 75 62 73 |..starte|r = subs|
|00001cb0| 74 72 28 24 30 2c 20 52 | 53 54 41 52 54 2c 20 52 |tr($0, R|START, R|
|00001cc0| 4c 45 4e 47 54 48 29 20 | 23 63 6f 70 79 20 69 74 |LENGTH) |#copy it|
|00001cd0| 0d 09 09 24 30 20 3d 20 | 73 74 61 72 74 65 72 20 |...$0 = |starter |
|00001ce0| 22 61 73 73 65 72 74 28 | 22 20 66 69 72 73 74 20 |"assert(|" first |
|00001cf0| 22 2c 20 5c 22 22 20 73 | 65 63 6f 6e 64 20 22 5c |", \"" s|econd "\|
|00001d00| 22 2c 20 22 20 46 4e 52 | 20 22 29 20 23 23 23 22 |", " FNR| ") ###"|
|00001d10| 0d 09 09 23 23 73 75 62 | 28 2f 61 5c 28 28 2e 2b |...##sub|(/a\((.+|
|00001d20| 29 5c 29 2f 2c 20 22 61 | 73 73 65 72 74 28 22 20 |)\)/, "a|ssert(" |
|00001d30| 66 69 72 73 74 20 22 2c | 20 5c 22 22 20 73 65 63 |first ",| \"" sec|
|00001d40| 6f 6e 64 20 22 5c 22 2c | 20 22 20 46 4e 52 20 22 |ond "\",| " FNR "|
|00001d50| 29 20 23 23 23 22 29 0d | 09 09 23 23 2d 64 65 6c |) ###").|..##-del|
|00001d60| 65 74 65 64 2c 20 64 6f | 65 73 6e 27 74 20 77 6f |eted, do|esn't wo|
|00001d70| 72 6b 20 70 72 6f 70 65 | 72 6c 79 20 69 66 20 22 |rk prope|rly if "|
|00001d80| 73 65 63 6f 6e 64 22 20 | 63 6f 6e 74 61 69 6e 73 |second" |contains|
|00001d90| 20 61 20 22 26 22 0d 09 | 09 7d 0d 09 6f 75 74 5b | a "&"..|.}..out[|
|00001da0| 2b 2b 69 5d 20 3d 20 24 | 30 0d 20 7d 0d 45 4e 44 |++i] = $|0. }.END|
|00001db0| 20 7b 09 63 6c 6f 73 65 | 28 6f 75 74 66 69 6c 65 | {.close|(outfile|
|00001dc0| 29 0d 09 09 66 6f 72 20 | 28 6a 20 3d 20 31 3b 20 |)...for |(j = 1; |
|00001dd0| 6a 20 3c 3d 20 69 3b 20 | 2b 2b 6a 29 0d 09 09 09 |j <= i; |++j)....|
|00001de0| 70 72 69 6e 74 20 6f 75 | 74 5b 6a 5d 20 3e 20 6f |print ou|t[j] > o|
|00001df0| 75 74 66 69 6c 65 0d 09 | 7d 0d 0d 0d 54 68 69 73 |utfile..|}...This|
|00001e00| 20 77 69 6c 6c 20 65 78 | 70 61 6e 64 20 79 6f 75 | will ex|pand you|
|00001e10| 72 20 61 62 62 72 65 76 | 69 61 74 69 6f 6e 73 20 |r abbrev|iations |
|00001e20| 69 6e 74 6f 20 70 72 6f | 70 65 72 20 61 73 73 65 |into pro|per asse|
|00001e30| 72 74 69 6f 6e 73 3a 0d | 09 61 73 73 65 72 74 28 |rtions:.|.assert(|
|00001e40| 78 31 20 3c 3d 20 35 30 | 2c 20 22 78 31 20 3c 3d |x1 <= 50|, "x1 <=|
|00001e50| 20 35 30 22 2c 20 64 64 | 64 29 20 23 23 23 2e 2e | 50", dd|d) ###..|
|00001e60| 2e 0d 09 61 73 73 65 72 | 74 28 6d 61 78 20 3e 20 |...asser|t(max > |
|00001e70| 30 20 26 26 20 6d 61 78 | 20 3c 20 31 30 30 30 2c |0 && max| < 1000,|
|00001e80| 20 22 6d 61 78 20 3e 20 | 30 20 26 26 20 6d 61 78 | "max > |0 && max|
|00001e90| 20 3c 20 31 30 30 30 22 | 2c 64 64 64 29 20 23 23 | < 1000"|,ddd) ##|
|00001ea0| 23 20 65 74 63 0d 77 68 | 65 72 65 20 64 64 64 20 |# etc.wh|ere ddd |
|00001eb0| 69 73 20 74 68 65 20 6c | 69 6e 65 20 6e 75 6d 62 |is the l|ine numb|
|00001ec0| 65 72 20 69 6e 20 79 6f | 75 72 20 70 72 6f 67 72 |er in yo|ur progr|
|00001ed0| 61 6d 2e 20 0d 0d 41 64 | 64 20 74 68 65 20 22 61 |am. ..Ad|d the "a|
|00001ee0| 73 73 65 72 74 22 20 66 | 75 6e 63 74 69 6f 6e 20 |ssert" f|unction |
|00001ef0| 61 62 6f 76 65 20 74 6f | 20 79 6f 75 72 20 70 72 |above to| your pr|
|00001f00| 6f 67 72 61 6d 20 74 6f | 6f 21 0d 0d 09 46 75 6e |ogram to|o!...Fun|
|00001f10| 63 74 69 6f 6e 20 66 6c | 6f 77 0d 54 72 61 63 69 |ction fl|ow.Traci|
|00001f20| 6e 67 20 66 75 6e 63 74 | 69 6f 6e 20 66 6c 6f 77 |ng funct|ion flow|
|00001f30| 20 63 61 6e 20 62 65 20 | 64 6f 6e 65 20 62 79 20 | can be |done by |
|00001f40| 69 6e 73 65 72 74 69 6e | 67 20 70 72 69 6e 74 20 |insertin|g print |
|00001f50| 73 74 61 74 65 6d 65 6e | 74 73 0d 61 74 20 74 68 |statemen|ts.at th|
|00001f60| 65 20 73 74 61 72 74 20 | 61 6e 64 20 65 6e 64 20 |e start |and end |
|00001f70| 6f 66 20 65 61 63 68 20 | 66 75 6e 63 74 69 6f 6e |of each |function|
|00001f80| 2c 20 65 67 3a 0d 09 66 | 75 6e 63 74 69 6f 6e 20 |, eg:..f|unction |
|00001f90| 61 5f 66 75 6e 63 28 61 | 72 67 73 2e 2e 2e 29 0d |a_func(a|rgs...).|
|00001fa0| 09 09 7b 0d 09 09 70 72 | 69 6e 74 20 22 45 6e 74 |..{...pr|int "Ent|
|00001fb0| 65 72 69 6e 67 3a 22 22 | 61 5f 66 75 6e 63 22 0d |ering:""|a_func".|
|00001fc0| 09 09 2e 2e 2e 62 6f 64 | 79 20 6f 66 20 66 75 6e |.....bod|y of fun|
|00001fd0| 63 74 69 6f 6e 0d 09 09 | 70 72 69 6e 74 20 22 4c |ction...|print "L|
|00001fe0| 65 61 76 69 6e 67 3a 22 | 22 61 5f 66 75 6e 63 22 |eaving:"|"a_func"|
|00001ff0| 0d 09 09 72 65 74 75 72 | 6e 20 73 6f 6d 65 74 68 |...retur|n someth|
|00002000| 69 6e 67 0d 09 09 7d 0d | 74 68 6f 75 67 68 20 74 |ing...}.|though t|
|00002010| 68 65 20 22 4c 65 61 76 | 69 6e 67 22 20 73 74 61 |he "Leav|ing" sta|
|00002020| 74 65 6d 65 6e 74 73 20 | 72 65 71 75 69 72 65 20 |tements |require |
|00002030| 6d 6f 72 65 20 63 61 72 | 65 2c 20 61 73 20 79 6f |more car|e, as yo|
|00002040| 75 72 20 66 75 6e 63 74 | 69 6f 6e 0d 6d 69 67 68 |ur funct|ion.migh|
|00002050| 74 20 68 61 76 65 20 73 | 65 76 65 72 61 6c 20 22 |t have s|everal "|
|00002060| 72 65 74 75 72 6e 22 20 | 73 74 61 74 65 6d 65 6e |return" |statemen|
|00002070| 74 73 2e 20 4f 66 74 65 | 6e 2c 20 6a 75 73 74 20 |ts. Ofte|n, just |
|00002080| 74 68 65 20 22 45 6e 74 | 65 72 69 6e 67 22 0d 70 |the "Ent|ering".p|
|00002090| 72 69 6e 74 20 73 74 61 | 74 65 6d 65 6e 74 73 20 |rint sta|tements |
|000020a0| 70 72 6f 76 69 64 65 20 | 65 6e 6f 75 67 68 20 69 |provide |enough i|
|000020b0| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 66 6f 72 20 64 |nformati|on for d|
|000020c0| 65 62 75 67 67 69 6e 67 | 2e 0d 0d 09 46 75 6e 63 |ebugging|....Func|
|000020d0| 74 69 6f 6e 20 66 6c 6f | 77 20 74 68 65 20 65 61 |tion flo|w the ea|
|000020e0| 73 79 20 77 61 79 0d 22 | 45 6e 74 65 72 69 6e 67 |sy way."|Entering|
|000020f0| 22 20 70 72 69 6e 74 20 | 73 74 61 74 65 6d 65 6e |" print |statemen|
|00002100| 74 73 20 63 61 6e 20 62 | 65 20 69 6e 73 65 72 74 |ts can b|e insert|
|00002110| 65 64 20 77 69 74 68 20 | 74 68 65 20 66 6f 6c 6c |ed with |the foll|
|00002120| 6f 77 69 6e 67 0d 68 41 | 57 4b 20 70 72 6f 67 72 |owing.hA|WK progr|
|00002130| 61 6d 20 28 6f 6e 63 65 | 20 61 67 61 69 6e 20 79 |am (once| again y|
|00002140| 6f 75 72 20 6f 72 69 67 | 69 6e 61 6c 20 70 72 6f |our orig|inal pro|
|00002150| 67 72 61 6d 20 77 69 6c | 6c 20 62 65 0d 6f 76 65 |gram wil|l be.ove|
|00002160| 72 77 72 69 74 74 65 6e | 2c 20 73 6f 20 75 73 65 |rwritten|, so use|
|00002170| 20 61 20 63 6f 70 79 29 | 3a 0d 0d 23 24 45 6e 74 | a copy)|:..#$Ent|
|00002180| 65 72 69 6e 67 46 75 6e | 63 74 69 6f 6e 3a 20 61 |eringFun|ction: a|
|00002190| 64 20 64 65 62 75 67 67 | 69 6e 67 20 74 6f 20 61 |d debugg|ing to a|
|000021a0| 20 70 72 6f 67 72 61 6d | 20 77 69 74 68 20 66 75 | program| with fu|
|000021b0| 6e 63 74 69 6f 6e 73 2c | 0d 23 20 69 6e 73 65 72 |nctions,|.# inser|
|000021c0| 74 69 6e 67 20 70 72 69 | 6e 74 20 73 74 61 74 65 |ting pri|nt state|
|000021d0| 6d 65 6e 74 73 20 61 74 | 20 62 65 67 69 6e 6e 69 |ments at| beginni|
|000021e0| 6e 67 20 6f 66 20 65 61 | 63 68 20 66 75 6e 63 74 |ng of ea|ch funct|
|000021f0| 69 6f 6e 2e 0d 23 20 50 | 61 73 73 20 69 74 20 79 |ion..# P|ass it y|
|00002200| 6f 75 72 20 70 72 6f 62 | 6c 65 6d 20 70 72 6f 67 |our prob|lem prog|
|00002210| 72 61 6d 20 61 73 20 74 | 68 65 20 73 69 6e 67 6c |ram as t|he singl|
|00002220| 65 20 69 6e 70 75 74 20 | 66 69 6c 65 3a 0d 23 20 |e input |file:.# |
|00002230| 6f 76 65 72 77 72 69 74 | 65 73 20 74 68 65 20 66 |overwrit|es the f|
|00002240| 69 6c 65 2c 20 73 6f 20 | 75 73 65 20 61 20 63 6f |ile, so |use a co|
|00002250| 70 79 2e 0d 46 4e 52 20 | 3d 3d 20 31 20 7b 6f 75 |py..FNR |== 1 {ou|
|00002260| 74 66 69 6c 65 20 3d 20 | 46 49 4c 45 4e 41 4d 45 |tfile = |FILENAME|
|00002270| 7d 0d 09 7b 0d 09 69 66 | 20 28 6d 61 74 63 68 28 |}..{..if| (match(|
|00002280| 24 30 2c 20 2f 5e 5b 20 | 5c 74 5d 2a 66 75 6e 63 |$0, /^[ |\t]*func|
|00002290| 2f 29 29 20 23 73 74 61 | 72 74 20 6f 66 20 66 75 |/)) #sta|rt of fu|
|000022a0| 6e 63 74 69 6f 6e 20 64 | 65 66 69 6e 69 74 69 6f |nction d|efinitio|
|000022b0| 6e 0d 09 09 7b 0d 09 09 | 6e 61 6d 65 20 3d 20 24 |n...{...|name = $|
|000022c0| 32 0d 09 09 6c 65 6e 20 | 3d 20 69 6e 64 65 78 28 |2...len |= index(|
|000022d0| 6e 61 6d 65 2c 20 22 28 | 22 29 0d 09 09 69 66 20 |name, "(|")...if |
|000022e0| 28 6c 65 6e 2b 30 20 3e | 20 31 29 0d 09 09 09 6e |(len+0 >| 1)....n|
|000022f0| 61 6d 65 20 3d 20 73 75 | 62 73 74 72 28 6e 61 6d |ame = su|bstr(nam|
|00002300| 65 2c 31 2c 6c 65 6e 2d | 31 29 0d 09 09 6f 75 74 |e,1,len-|1)...out|
|00002310| 5b 2b 2b 69 5d 20 3d 20 | 24 30 0d 09 09 23 20 53 |[++i] = |$0...# S|
|00002320| 6b 69 70 20 6f 76 65 72 | 20 6f 70 65 6e 69 6e 67 |kip over| opening|
|00002330| 20 6c 65 66 74 20 63 75 | 72 6c 79 20 6f 66 20 66 | left cu|rly of f|
|00002340| 75 6e 63 74 69 6f 6e 0d | 09 09 69 66 20 28 24 30 |unction.|..if ($0|
|00002350| 20 21 7e 20 2f 7b 2f 29 | 0d 09 09 09 7b 0d 09 09 | !~ /{/)|....{...|
|00002360| 09 64 6f 0d 09 09 09 09 | 7b 0d 09 09 09 09 67 65 |.do.....|{.....ge|
|00002370| 74 6c 69 6e 65 0d 09 09 | 09 09 6f 75 74 5b 2b 2b |tline...|..out[++|
|00002380| 69 5d 20 3d 20 24 30 0d | 09 09 09 09 7d 20 77 68 |i] = $0.|....} wh|
|00002390| 69 6c 65 20 28 24 30 20 | 21 7e 20 2f 7b 2f 29 3b |ile ($0 |!~ /{/);|
|000023a0| 0d 09 09 09 7d 0d 09 09 | 6f 75 74 5b 2b 2b 69 5d |....}...|out[++i]|
|000023b0| 20 3d 20 22 70 72 69 6e | 74 20 5c 22 45 6e 74 65 | = "prin|t \"Ente|
|000023c0| 72 69 6e 67 3a 20 5c 22 | 5c 22 22 20 6e 61 6d 65 |ring: \"|\"" name|
|000023d0| 20 22 5c 22 20 23 23 23 | 22 0d 09 09 7d 0d 09 65 | "\" ###|"...}..e|
|000023e0| 6c 73 65 0d 09 09 6f 75 | 74 5b 2b 2b 69 5d 20 3d |lse...ou|t[++i] =|
|000023f0| 20 24 30 0d 09 7d 0d 45 | 4e 44 20 7b 09 63 6c 6f | $0..}.E|ND {.clo|
|00002400| 73 65 28 6f 75 74 66 69 | 6c 65 29 0d 09 09 66 6f |se(outfi|le)...fo|
|00002410| 72 20 28 6a 20 3d 20 31 | 3b 20 6a 20 3c 3d 20 69 |r (j = 1|; j <= i|
|00002420| 3b 20 2b 2b 6a 29 0d 09 | 09 09 70 72 69 6e 74 20 |; ++j)..|..print |
|00002430| 6f 75 74 5b 6a 5d 20 3e | 20 6f 75 74 66 69 6c 65 |out[j] >| outfile|
|00002440| 0d 09 7d 0d 0d 59 6f 75 | 27 6c 6c 20 66 69 6e 64 |..}..You|'ll find|
|00002450| 20 74 68 69 73 20 70 72 | 6f 67 72 61 6d 20 69 6e | this pr|ogram in|
|00002460| 20 79 6f 75 72 20 22 68 | 41 57 4b 20 70 72 6f 67 | your "h|AWK prog|
|00002470| 72 61 6d 73 22 20 66 6f | 6c 64 65 72 2e 0d 0d 09 |rams" fo|lder....|
|00002480| 53 65 6e 64 69 6e 67 20 | 64 69 61 67 6f 73 74 69 |Sending |diagosti|
|00002490| 63 73 20 74 6f 20 73 74 | 64 65 72 72 0d 49 66 20 |cs to st|derr.If |
|000024a0| 79 6f 75 72 20 70 72 6f | 67 72 61 6d 20 77 72 69 |your pro|gram wri|
|000024b0| 74 65 73 20 74 6f 20 73 | 74 64 6f 75 74 20 61 6e |tes to s|tdout an|
|000024c0| 64 20 79 6f 75 27 64 20 | 72 61 74 68 65 72 20 72 |d you'd |rather r|
|000024d0| 65 64 69 72 65 63 74 20 | 79 6f 75 72 0d 6f 75 74 |edirect |your.out|
|000024e0| 70 75 74 20 74 6f 20 61 | 20 64 69 66 66 65 72 65 |put to a| differe|
|000024f0| 6e 74 20 66 69 6c 65 20 | 74 6f 20 6d 61 6b 65 20 |nt file |to make |
|00002500| 74 68 69 6e 67 73 20 65 | 61 73 69 65 72 20 74 6f |things e|asier to|
|00002510| 20 72 65 61 64 2c 20 74 | 68 65 6e 20 69 6e 73 74 | read, t|hen inst|
|00002520| 65 61 64 0d 6f 66 20 6a | 75 73 74 20 61 20 70 6c |ead.of j|ust a pl|
|00002530| 61 69 6e 20 22 70 72 69 | 6e 74 22 20 66 6f 72 20 |ain "pri|nt" for |
|00002540| 79 6f 75 72 20 64 65 62 | 75 67 67 69 6e 67 0d 09 |your deb|ugging..|
|00002550| 09 70 72 69 6e 74 20 22 | 44 65 62 75 67 67 69 6e |.print "|Debuggin|
|00002560| 67 20 6f 72 20 65 72 72 | 6f 72 20 6d 65 73 73 61 |g or err|or messa|
|00002570| 67 65 22 0d 79 6f 75 20 | 63 61 6e 20 75 73 65 0d |ge".you |can use.|
|00002580| 09 09 70 72 69 6e 74 28 | 22 44 65 62 75 67 67 69 |..print(|"Debuggi|
|00002590| 6e 67 20 6f 72 20 65 72 | 72 6f 72 20 6d 65 73 73 |ng or er|ror mess|
|000025a0| 61 67 65 22 29 20 3e 20 | 22 73 74 64 65 72 72 22 |age") > |"stderr"|
|000025b0| 0d 54 68 69 73 20 77 69 | 6c 6c 20 73 65 6e 64 20 |.This wi|ll send |
|000025c0| 64 69 61 67 6e 6f 73 74 | 69 63 73 20 74 6f 20 74 |diagnost|ics to t|
|000025d0| 68 65 20 66 69 6c 65 20 | 24 74 65 6d 70 53 74 64 |he file |$tempStd|
|000025e0| 45 72 72 2e 20 54 68 65 | 20 70 61 72 65 6e 74 68 |Err. The| parenth|
|000025f0| 65 73 69 7a 65 64 0d 66 | 6f 72 6d 20 6f 66 20 74 |esized.f|orm of t|
|00002600| 68 65 20 70 72 69 6e 74 | 20 73 74 61 74 65 6d 65 |he print| stateme|
|00002610| 6e 74 20 73 68 6f 75 6c | 64 20 62 65 20 75 73 65 |nt shoul|d be use|
|00002620| 64 20 74 6f 20 6d 61 6b | 65 20 69 74 20 63 6c 65 |d to mak|e it cle|
|00002630| 61 72 20 74 6f 20 74 68 | 65 0d 69 6e 74 65 72 70 |ar to th|e.interp|
|00002640| 72 65 74 65 72 20 74 68 | 61 74 20 22 3e 22 20 6d |reter th|at ">" m|
|00002650| 65 61 6e 73 20 22 72 65 | 64 69 72 65 63 74 22 2c |eans "re|direct",|
|00002660| 20 6e 6f 74 20 22 67 72 | 65 61 74 65 72 20 74 68 | not "gr|eater th|
|00002670| 61 6e 22 2e 0d 0d 46 6f | 72 20 65 78 61 6d 70 6c |an"...Fo|r exampl|
|00002680| 65 2c 20 74 6f 20 70 72 | 69 6e 74 20 61 73 73 65 |e, to pr|int asse|
|00002690| 72 74 69 6f 6e 73 20 74 | 6f 20 24 74 65 6d 70 53 |rtions t|o $tempS|
|000026a0| 74 64 45 72 72 20 79 6f | 75 20 63 6f 75 6c 64 20 |tdErr yo|u could |
|000026b0| 75 73 65 0d 09 66 75 6e | 63 74 69 6f 6e 20 61 73 |use..fun|ction as|
|000026c0| 73 65 72 74 28 65 78 70 | 72 2c 20 6d 65 73 73 61 |sert(exp|r, messa|
|000026d0| 67 65 2c 20 6c 69 6e 65 | 29 0d 09 09 7b 0d 09 09 |ge, line|)...{...|
|000026e0| 69 66 20 28 21 65 78 70 | 72 29 0d 09 09 09 70 72 |if (!exp|r)....pr|
|000026f0| 69 6e 74 20 28 22 41 73 | 73 65 72 74 69 6f 6e 20 |int ("As|sertion |
|00002700| 66 6c 75 6e 6b 65 64 3a | 22 2c 20 6d 65 73 73 61 |flunked:|", messa|
|00002710| 67 65 2c 20 22 61 74 22 | 2c 20 6c 69 6e 65 29 20 |ge, "at"|, line) |
|00002720| 3e 20 22 73 74 64 65 72 | 72 22 0d 09 09 7d 0d 41 |> "stder|r"...}.A|
|00002730| 6e 64 20 74 6f 20 73 65 | 6e 64 20 66 75 6e 63 74 |nd to se|nd funct|
|00002740| 69 6f 6e 20 66 6c 6f 77 | 20 6d 65 73 73 61 67 65 |ion flow| message|
|00002750| 73 20 74 6f 20 73 74 64 | 65 72 72 2c 20 72 65 70 |s to std|err, rep|
|00002760| 6c 61 63 65 20 74 68 65 | 20 61 70 70 72 6f 70 72 |lace the| appropr|
|00002770| 69 61 74 65 0d 6c 69 6e | 65 20 69 6e 20 24 45 6e |iate.lin|e in $En|
|00002780| 74 65 72 69 6e 67 46 75 | 6e 63 74 69 6f 6e 20 77 |teringFu|nction w|
|00002790| 69 74 68 0d 09 6f 75 74 | 5b 2b 2b 69 5d 20 3d 20 |ith..out|[++i] = |
|000027a0| 22 70 72 69 6e 74 28 20 | 5c 22 45 6e 74 65 72 69 |"print( |\"Enteri|
|000027b0| 6e 67 3a 20 5c 22 5c 22 | 22 20 6e 61 6d 65 20 22 |ng: \"\"|" name "|
|000027c0| 5c 22 29 20 3e 20 5c 22 | 73 74 64 65 72 72 5c 22 |\") > \"|stderr\"|
|000027d0| 20 23 23 23 22 0d 0d 54 | 68 65 20 24 74 65 6d 70 | ###"..T|he $temp|
|000027e0| 53 74 64 45 72 72 20 66 | 69 6c 65 20 77 69 6c 6c |StdErr f|ile will|
|000027f0| 20 6e 6f 74 20 62 65 20 | 6f 70 65 6e 65 64 20 66 | not be |opened f|
|00002800| 6f 72 20 79 6f 75 20 61 | 75 74 6f 6d 61 74 69 63 |or you a|utomatic|
|00002810| 61 6c 6c 79 20 61 66 74 | 65 72 20 61 20 72 75 6e |ally aft|er a run|
|00002820| 2c 0d 73 6f 20 72 65 6d | 65 6d 62 65 72 20 74 6f |,.so rem|ember to|
|00002830| 20 6f 70 65 6e 20 69 74 | 20 61 6e 64 20 74 61 6b | open it| and tak|
|00002840| 65 20 61 20 6c 6f 6f 6b | 20 69 66 20 79 6f 75 20 |e a look| if you |
|00002850| 73 65 6e 64 20 6d 65 73 | 73 61 67 65 73 20 74 68 |send mes|sages th|
|00002860| 65 72 65 2e 0d 0d 09 68 | 41 57 4b 20 69 73 6e 27 |ere....h|AWK isn'|
|00002870| 74 20 43 0d 68 41 57 4b | 20 64 65 63 6c 61 72 65 |t C.hAWK| declare|
|00002880| 73 20 76 61 72 69 61 62 | 6c 65 73 20 66 6f 72 20 |s variab|les for |
|00002890| 79 6f 75 2c 20 68 61 70 | 70 69 6c 79 20 63 6f 6e |you, hap|pily con|
|000028a0| 63 61 74 65 6e 61 74 65 | 73 20 6a 75 73 74 20 61 |catenate|s just a|
|000028b0| 62 6f 75 74 20 61 6e 79 | 74 68 69 6e 67 0d 77 69 |bout any|thing.wi|
|000028c0| 74 68 20 61 6e 79 74 68 | 69 6e 67 2c 20 61 63 63 |th anyth|ing, acc|
|000028d0| 65 70 74 73 20 66 75 6e | 63 74 69 6f 6e 73 20 77 |epts fun|ctions w|
|000028e0| 69 74 68 20 61 20 76 61 | 72 69 61 62 6c 65 20 6e |ith a va|riable n|
|000028f0| 75 6d 62 65 72 20 6f 66 | 20 61 72 67 75 6d 65 6e |umber of| argumen|
|00002900| 74 73 2c 0d 64 6f 65 73 | 6e 27 74 20 6d 69 6e 64 |ts,.does|n't mind|
|00002910| 20 69 66 20 79 6f 75 20 | 75 73 65 20 61 20 6e 61 | if you |use a na|
|00002920| 6d 65 20 61 73 20 61 20 | 6e 75 6d 62 65 72 2c 20 |me as a |number, |
|00002930| 61 20 73 74 72 69 6e 67 | 2c 20 41 4e 44 20 61 6e |a string|, AND an|
|00002940| 20 61 72 72 61 79 0d 61 | 6c 6c 20 69 6e 20 74 68 | array.a|ll in th|
|00002950| 65 20 73 61 6d 65 20 70 | 72 6f 67 72 61 6d 2c 20 |e same p|rogram, |
|00002960| 61 6e 64 20 6a 75 73 74 | 20 6c 6f 76 65 73 20 74 |and just| loves t|
|00002970| 6f 20 70 72 69 6e 74 20 | 74 68 65 20 63 75 72 72 |o print |the curr|
|00002980| 65 6e 74 20 72 65 63 6f | 72 64 20 74 6f 0d 73 74 |ent reco|rd to.st|
|00002990| 64 6f 75 74 20 75 6e 6c | 65 73 73 20 79 6f 75 20 |dout unl|ess you |
|000029a0| 73 61 79 20 6f 74 68 65 | 72 77 69 73 65 2e 20 54 |say othe|rwise. T|
|000029b0| 6f 20 73 6f 6d 65 20 65 | 78 74 65 6e 74 20 74 68 |o some e|xtent th|
|000029c0| 69 73 20 69 73 20 22 74 | 6f 6f 20 6d 75 63 68 20 |is is "t|oo much |
|000029d0| 6f 66 20 61 0d 67 6f 6f | 64 20 74 68 69 6e 67 22 |of a.goo|d thing"|
|000029e0| 2c 20 61 6e 64 20 69 74 | 20 63 65 72 74 61 69 6e |, and it| certain|
|000029f0| 6c 79 20 74 61 6b 65 73 | 20 67 65 74 74 69 6e 67 |ly takes| getting|
|00002a00| 20 75 73 65 64 20 74 6f | 2e 20 54 68 65 20 22 43 | used to|. The "C|
|00002a10| 6f 6d 6d 6f 6e 20 62 75 | 67 73 22 0d 73 65 63 74 |ommon bu|gs".sect|
|00002a20| 69 6f 6e 20 62 65 6c 6f | 77 20 69 73 20 6d 6f 73 |ion belo|w is mos|
|00002a30| 74 6c 79 20 61 20 6c 69 | 73 74 20 6f 66 20 74 68 |tly a li|st of th|
|00002a40| 69 6e 67 73 20 74 68 61 | 74 20 68 41 57 4b 20 64 |ings tha|t hAWK d|
|00002a50| 6f 65 73 20 64 69 66 66 | 65 72 65 6e 74 6c 79 20 |oes diff|erently |
|00002a60| 66 72 6f 6d 0d 43 2c 20 | 61 6e 64 20 61 20 71 75 |from.C, |and a qu|
|00002a70| 69 63 6b 20 62 72 6f 77 | 73 65 20 74 68 72 6f 75 |ick brow|se throu|
|00002a80| 67 68 20 77 69 6c 6c 20 | 68 65 6c 70 20 79 6f 75 |gh will |help you|
|00002a90| 20 61 76 6f 69 64 20 70 | 72 6f 67 72 61 6d 6d 69 | avoid p|rogrammi|
|00002aa0| 6e 67 20 69 6e 20 74 68 | 65 0d 77 72 6f 6e 67 20 |ng in th|e.wrong |
|00002ab0| 6c 61 6e 67 75 61 67 65 | 2e 0d 0d 2d 2d 2d 2d 2d |language|...-----|
|00002ac0| 2d 2d 2d 2d 2d 0d 43 6f | 6d 6d 6f 6e 20 62 75 67 |-----.Co|mmon bug|
|00002ad0| 73 0d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 0d 55 6e 63 |s.------|----.Unc|
|00002ae0| 6f 6d 6d 65 6e 74 65 64 | 20 63 6f 6d 6d 65 6e 74 |ommented| comment|
|00002af0| 3a 20 69 66 20 79 6f 75 | 20 6a 75 73 74 20 63 61 |: if you| just ca|
|00002b00| 6e 27 74 20 66 69 6e 64 | 20 74 68 65 20 62 75 67 |n't find| the bug|
|00002b10| 2c 20 72 65 72 65 61 64 | 20 79 6f 75 72 20 70 72 |, reread| your pr|
|00002b20| 6f 67 72 61 6d 0d 61 6e | 64 20 6c 6f 6f 6b 20 66 |ogram.an|d look f|
|00002b30| 6f 72 20 61 20 6c 69 6e | 65 20 74 68 61 74 20 73 |or a lin|e that s|
|00002b40| 68 6f 75 6c 64 20 62 65 | 20 61 20 63 6f 6d 6d 65 |hould be| a comme|
|00002b50| 6e 74 20 62 75 74 20 69 | 73 6e 27 74 2e 20 46 6f |nt but i|sn't. Fo|
|00002b60| 72 67 65 74 74 69 6e 67 | 20 74 6f 20 70 75 74 0d |rgetting| to put.|
|00002b70| 74 68 65 20 22 23 22 20 | 61 74 20 74 68 65 20 73 |the "#" |at the s|
|00002b80| 74 61 72 74 20 6f 66 20 | 61 20 63 6f 6d 6d 65 6e |tart of |a commen|
|00002b90| 74 20 64 6f 65 73 6e 27 | 74 20 61 6c 77 61 79 73 |t doesn'|t always|
|00002ba0| 20 63 61 75 73 65 20 61 | 20 73 79 6e 74 61 78 20 | cause a| syntax |
|00002bb0| 65 72 72 6f 72 3b 0d 6f | 66 74 65 6e 20 68 41 57 |error;.o|ften hAW|
|00002bc0| 4b 20 77 69 6c 6c 20 65 | 78 65 63 75 74 65 20 74 |K will e|xecute t|
|00002bd0| 68 65 20 74 65 78 74 20 | 61 73 20 74 68 6f 75 67 |he text |as thoug|
|00002be0| 68 20 69 74 20 77 65 72 | 65 20 63 6f 64 65 20 77 |h it wer|e code w|
|00002bf0| 69 74 68 6f 75 74 20 65 | 72 72 6f 72 2c 0d 61 6e |ithout e|rror,.an|
|00002c00| 64 20 69 66 20 74 68 65 | 20 74 65 78 74 20 69 6e |d if the| text in|
|00002c10| 76 6f 6c 76 65 73 20 61 | 6e 79 20 76 61 72 69 61 |volves a|ny varia|
|00002c20| 62 6c 65 73 20 79 6f 75 | 20 75 73 65 20 69 6e 20 |bles you| use in |
|00002c30| 79 6f 75 72 20 70 72 6f | 67 72 61 6d 20 74 68 65 |your pro|gram the|
|00002c40| 6e 0d 6f 64 64 20 74 68 | 69 6e 67 73 20 63 61 6e |n.odd th|ings can|
|00002c50| 20 68 61 70 70 65 6e 2e | 20 54 79 70 69 63 61 6c | happen.| Typical|
|00002c60| 20 73 79 6d 70 74 6f 6d | 73 20 61 72 65 20 74 68 | symptom|s are th|
|00002c70| 61 74 20 6c 69 6e 65 73 | 20 61 72 65 20 70 72 69 |at lines| are pri|
|00002c80| 6e 74 65 64 20 74 6f 0d | 73 74 64 6f 75 74 20 74 |nted to.|stdout t|
|00002c90| 68 61 74 20 79 6f 75 20 | 64 69 64 6e 27 74 20 65 |hat you |didn't e|
|00002ca0| 78 70 65 63 74 2c 20 6f | 72 20 79 6f 75 20 63 61 |xpect, o|r you ca|
|00002cb0| 6e 27 74 20 73 65 65 6d | 20 74 6f 20 73 65 74 20 |n't seem| to set |
|00002cc0| 74 68 65 20 76 61 6c 75 | 65 20 6f 66 20 61 0d 76 |the valu|e of a.v|
|00002cd0| 61 72 69 61 62 6c 65 2e | 0d 57 61 74 63 68 20 66 |ariable.|.Watch f|
|00002ce0| 6f 72 20 74 68 69 6e 67 | 73 20 6c 69 6b 65 0d 09 |or thing|s like..|
|00002cf0| 23 53 65 74 74 69 6e 67 | 0d 09 09 09 78 20 3d 20 |#Setting|....x = |
|00002d00| 2d 31 0d 09 23 77 69 6c | 6c 20 73 68 75 74 20 6f |-1..#wil|l shut o|
|00002d10| 66 66 20 61 6c 6c 20 70 | 72 6f 67 72 65 73 73 20 |ff all p|rogress |
|00002d20| 64 69 61 6c 6f 67 73 2c | 0d 09 23 66 6f 72 20 71 |dialogs,|..#for q|
|00002d30| 75 69 65 74 20 72 75 6e | 6e 69 6e 67 2e 0d 2d 2d |uiet run|ning..--|
|00002d40| 68 65 72 65 2c 20 22 78 | 20 3d 20 2d 31 22 20 77 |here, "x| = -1" w|
|00002d50| 6f 75 6c 64 20 62 65 20 | 69 6e 74 65 72 70 72 65 |ould be |interpre|
|00002d60| 74 65 64 20 61 73 20 61 | 20 70 61 74 74 65 72 6e |ted as a| pattern|
|00002d70| 3b 20 69 74 20 77 6f 75 | 6c 64 20 61 6c 77 61 79 |; it wou|ld alway|
|00002d80| 73 0d 65 76 61 6c 75 61 | 74 65 20 74 6f 20 6e 6f |s.evalua|te to no|
|00002d90| 6e 7a 65 72 6f 2c 20 73 | 6f 20 61 6c 6c 20 6c 69 |nzero, s|o all li|
|00002da0| 6e 65 73 20 6f 66 20 69 | 6e 70 75 74 20 77 6f 75 |nes of i|nput wou|
|00002db0| 6c 64 20 62 65 20 70 72 | 69 6e 74 65 64 20 74 6f |ld be pr|inted to|
|00002dc0| 20 73 74 64 6f 75 74 0d | 28 74 68 65 20 64 65 66 | stdout.|(the def|
|00002dd0| 61 75 6c 74 20 61 63 74 | 69 6f 6e 20 69 66 20 6e |ault act|ion if n|
|00002de0| 6f 20 61 63 74 69 6f 6e | 20 69 73 20 67 69 76 65 |o action| is give|
|00002df0| 6e 29 2e 0d 6f 72 0d 09 | 78 20 3d 20 2d 31 3b 20 |n)..or..|x = -1; |
|00002e00| 09 78 20 3d 20 30 20 77 | 69 6c 6c 20 65 6e 61 62 |.x = 0 w|ill enab|
|00002e10| 6c 65 20 64 6c 6f 67 73 | 0d 2d 2d 68 65 72 65 2c |le dlogs|.--here,|
|00002e20| 20 78 20 77 6f 75 6c 64 | 20 68 61 76 65 20 74 68 | x would| have th|
|00002e30| 65 20 76 61 6c 75 65 20 | 22 30 22 2c 20 20 61 73 |e value |"0", as|
|00002e40| 20 61 20 72 65 73 75 6c | 74 20 6f 66 20 63 6f 6e | a resul|t of con|
|00002e50| 63 61 74 65 6e 61 74 69 | 6e 67 20 22 30 22 0d 77 |catenati|ng "0".w|
|00002e60| 69 74 68 20 74 68 65 20 | 28 70 72 65 73 75 6d 61 |ith the |(presuma|
|00002e70| 62 6c 79 29 20 75 6e 61 | 73 73 69 67 6e 65 64 20 |bly) una|ssigned |
|00002e80| 76 61 72 69 61 62 6c 65 | 73 20 22 77 69 6c 6c 22 |variable|s "will"|
|00002e90| 2c 20 22 65 6e 61 62 6c | 65 22 2c 20 61 6e 64 20 |, "enabl|e", and |
|00002ea0| 22 64 6c 6f 67 73 22 2c | 0d 6f 76 65 72 72 69 64 |"dlogs",|.overrid|
|00002eb0| 69 6e 67 20 74 68 65 20 | 70 72 65 76 69 6f 75 73 |ing the |previous|
|00002ec0| 20 22 78 20 3d 20 2d 31 | 22 20 61 73 73 69 67 6e | "x = -1|" assign|
|00002ed0| 6d 65 6e 74 2e 20 53 74 | 72 61 6e 67 65 2c 20 62 |ment. St|range, b|
|00002ee0| 75 74 20 74 72 75 65 2e | 0d 0d 53 70 65 6c 6c 69 |ut true.|..Spelli|
|00002ef0| 6e 67 20 65 72 72 6f 72 | 3a 20 74 68 65 20 64 72 |ng error|: the dr|
|00002f00| 61 77 62 61 63 6b 20 6f | 66 20 6e 6f 74 20 68 61 |awback o|f not ha|
|00002f10| 76 69 6e 67 20 74 6f 20 | 64 65 63 6c 61 72 65 20 |ving to |declare |
|00002f20| 76 61 72 69 61 62 6c 65 | 73 20 69 6e 20 68 41 57 |variable|s in hAW|
|00002f30| 4b 20 69 73 0d 74 68 61 | 74 20 61 20 73 70 65 6c |K is.tha|t a spel|
|00002f40| 6c 69 6e 67 20 65 72 72 | 6f 72 20 63 61 6e 20 61 |ling err|or can a|
|00002f50| 63 63 69 64 65 6e 74 61 | 6c 6c 79 20 63 72 65 61 |ccidenta|lly crea|
|00002f60| 74 65 20 61 20 6e 65 77 | 20 76 61 72 69 61 62 6c |te a new| variabl|
|00002f70| 65 2e 20 46 6f 72 20 65 | 78 61 6d 70 6c 65 2c 0d |e. For e|xample,.|
|00002f80| 09 69 66 20 28 6d 61 78 | 4c 69 6e 65 73 20 3e 20 |.if (max|Lines > |
|00002f90| 35 30 29 0d 09 09 6d 61 | 78 6c 69 6e 65 73 20 3d |50)...ma|xlines =|
|00002fa0| 20 35 30 0d 77 6f 75 6c | 64 20 6e 65 76 65 72 20 | 50.woul|d never |
|00002fb0| 73 65 74 20 22 6d 61 78 | 4c 69 6e 65 73 22 20 2d |set "max|Lines" -|
|00002fc0| 20 69 74 20 77 6f 75 6c | 64 20 63 72 65 61 74 65 | it woul|d create|
|00002fd0| 20 61 20 6e 65 77 20 76 | 61 72 69 61 62 6c 65 20 | a new v|ariable |
|00002fe0| 22 6d 61 78 6c 69 6e 65 | 73 22 0d 61 6e 64 20 73 |"maxline|s".and s|
|00002ff0| 65 74 20 69 74 20 69 6e | 73 74 65 61 64 2e 20 49 |et it in|stead. I|
|00003000| 66 20 79 6f 75 20 73 75 | 73 70 65 63 74 20 61 20 |f you su|spect a |
|00003010| 73 70 65 6c 6c 69 6e 67 | 20 65 72 72 6f 72 20 69 |spelling| error i|
|00003020| 73 20 74 68 65 20 63 75 | 6c 70 72 69 74 20 62 75 |s the cu|lprit bu|
|00003030| 74 20 63 61 6e 27 74 0d | 73 70 6f 74 20 69 74 2c |t can't.|spot it,|
|00003040| 20 72 75 6e 20 24 57 6f | 72 64 46 72 65 71 75 65 | run $Wo|rdFreque|
|00003050| 6e 63 79 20 75 73 69 6e | 67 20 79 6f 75 72 20 70 |ncy usin|g your p|
|00003060| 72 6f 62 6c 65 6d 20 70 | 72 6f 67 72 61 6d 20 61 |roblem p|rogram a|
|00003070| 73 20 74 68 65 20 69 6e | 70 75 74 2e 0d 54 68 69 |s the in|put..Thi|
|00003080| 73 20 77 69 6c 6c 20 70 | 72 6f 64 75 63 65 20 61 |s will p|roduce a|
|00003090| 20 6c 69 73 74 20 6f 66 | 20 61 6c 6c 20 77 6f 72 | list of| all wor|
|000030a0| 64 73 20 69 6e 20 79 6f | 75 72 20 70 72 6f 67 72 |ds in yo|ur progr|
|000030b0| 61 6d 2c 20 6d 61 6b 69 | 6e 67 20 69 74 20 65 61 |am, maki|ng it ea|
|000030c0| 73 69 65 72 0d 74 6f 20 | 70 69 63 6b 20 6f 75 74 |sier.to |pick out|
|000030d0| 20 77 72 6f 6e 67 20 73 | 70 65 6c 6c 69 6e 67 73 | wrong s|pellings|
|000030e0| 2e 0d 0d 55 6e 69 6e 74 | 65 6e 74 69 6f 6e 61 6c |...Unint|entional|
|000030f0| 20 72 65 64 69 72 65 63 | 74 69 6f 6e 3a 20 22 67 | redirec|tion: "g|
|00003100| 65 74 6c 69 6e 65 22 20 | 72 65 74 75 72 6e 73 20 |etline" |returns |
|00003110| 30 20 61 74 20 65 6e 64 | 20 6f 66 20 66 69 6c 65 |0 at end| of file|
|00003120| 2c 20 2d 31 20 69 66 20 | 74 68 65 72 65 0d 69 73 |, -1 if |there.is|
|00003130| 20 61 20 70 72 6f 62 6c | 65 6d 20 72 65 61 64 69 | a probl|em readi|
|00003140| 6e 67 20 74 68 65 20 66 | 69 6c 65 2c 20 61 6e 64 |ng the f|ile, and|
|00003150| 20 31 20 69 66 20 61 6c | 6c 20 69 73 20 4f 4b 2e | 1 if al|l is OK.|
|00003160| 20 53 6f 20 77 68 61 74 | 20 64 6f 65 73 0d 09 69 | So what| does..i|
|00003170| 66 28 67 65 74 6c 69 6e | 65 20 3c 20 30 29 2e 2e |f(getlin|e < 0)..|
|00003180| 2e 2e 0d 64 6f 3f 20 49 | 74 20 61 74 74 65 6d 70 |...do? I|t attemp|
|00003190| 74 73 20 74 6f 20 72 65 | 61 64 20 66 72 6f 6d 20 |ts to re|ad from |
|000031a0| 74 68 65 20 66 69 6c 65 | 20 6e 61 6d 65 64 20 22 |the file| named "|
|000031b0| 30 22 2c 20 61 6e 64 20 | 75 73 75 61 6c 6c 79 20 |0", and |usually |
|000031c0| 64 6f 65 73 6e 27 74 20 | 73 75 63 63 65 65 64 2e |doesn't |succeed.|
|000031d0| 0d 49 66 20 79 6f 75 20 | 77 61 6e 74 20 74 6f 20 |.If you |want to |
|000031e0| 63 68 65 63 6b 20 74 68 | 61 74 20 67 65 74 6c 69 |check th|at getli|
|000031f0| 6e 65 20 69 73 20 6e 6f | 74 20 72 65 74 75 72 6e |ne is no|t return|
|00003200| 69 6e 67 20 2d 31 2c 20 | 75 73 65 0d 09 69 66 20 |ing -1, |use..if |
|00003210| 28 28 67 65 74 6c 69 6e | 65 29 20 3c 20 30 29 2e |((getlin|e) < 0).|
|00003220| 2e 2e 0d 45 76 65 6e 20 | 62 65 74 74 65 72 2c 20 |...Even |better, |
|00003230| 75 73 65 0d 09 69 66 28 | 67 65 74 6c 69 6e 65 20 |use..if(|getline |
|00003240| 3c 3d 20 30 29 2e 2e 2e | 2e 0d 6f 72 0d 09 77 68 |<= 0)...|..or..wh|
|00003250| 69 6c 65 20 28 67 65 74 | 6c 69 6e 65 20 3e 20 30 |ile (get|line > 0|
|00003260| 29 2e 2e 2e 2e 0d 69 6e | 73 74 65 61 64 2e 0d 0d |).....in|stead...|
|00003270| 45 6e 64 6c 65 73 73 20 | 67 65 74 6c 69 6e 65 20 |Endless |getline |
|00003280| 6c 6f 6f 70 3a 20 22 67 | 65 74 6c 69 6e 65 22 20 |loop: "g|etline" |
|00003290| 72 65 74 75 72 6e 73 20 | 30 20 6f 6e 6c 79 20 69 |returns |0 only i|
|000032a0| 66 20 69 74 20 68 61 73 | 20 73 75 63 63 65 73 73 |f it has| success|
|000032b0| 66 75 6c 6c 79 20 72 65 | 61 63 68 65 64 0d 74 68 |fully re|ached.th|
|000032c0| 65 20 65 6e 64 20 6f 66 | 20 61 20 66 69 6c 65 2e |e end of| a file.|
|000032d0| 20 49 66 20 74 68 65 72 | 65 20 69 73 20 61 20 70 | If ther|e is a p|
|000032e0| 72 6f 62 6c 65 6d 20 6f | 70 65 6e 69 6e 67 20 6f |roblem o|pening o|
|000032f0| 72 20 72 65 61 64 69 6e | 67 20 61 20 66 69 6c 65 |r readin|g a file|
|00003300| 2c 20 22 67 65 74 6c 69 | 6e 65 22 0d 72 65 74 75 |, "getli|ne".retu|
|00003310| 72 6e 73 20 2d 31 2e 20 | 53 6f 2c 0d 09 77 68 69 |rns -1. |So,..whi|
|00003320| 6c 65 20 28 67 65 74 6c | 69 6e 65 20 3c 20 74 68 |le (getl|ine < th|
|00003330| 65 46 49 6c 65 29 2e 2e | 2e 2e 0d 77 69 6c 6c 20 |eFIle)..|...will |
|00003340| 6c 6f 6f 70 20 66 6f 72 | 65 76 65 72 20 69 66 20 |loop for|ever if |
|00003350| 69 74 20 68 61 73 20 74 | 72 6f 75 62 6c 65 20 72 |it has t|rouble r|
|00003360| 65 61 64 69 6e 67 20 61 | 20 66 69 6c 65 2e 20 55 |eading a| file. U|
|00003370| 73 65 0d 09 77 68 69 6c | 65 20 28 67 65 74 6c 69 |se..whil|e (getli|
|00003380| 6e 65 20 3c 20 74 68 65 | 46 69 6c 65 20 3e 20 30 |ne < the|File > 0|
|00003390| 29 2e 2e 2e 2e 0d 69 6e | 73 74 65 61 64 2e 0d 0d |).....in|stead...|
|000033a0| 55 6e 61 73 73 69 67 6e | 65 64 20 76 61 72 69 61 |Unassign|ed varia|
|000033b0| 62 6c 65 3a 20 73 6f 6d | 65 74 69 6d 65 73 20 79 |ble: som|etimes y|
|000033c0| 6f 75 20 6d 61 79 20 77 | 69 73 68 20 74 6f 20 73 |ou may w|ish to s|
|000033d0| 61 66 65 67 75 61 72 64 | 20 61 67 61 69 6e 73 74 |afeguard| against|
|000033e0| 20 66 6f 72 67 65 74 74 | 69 6e 67 0d 74 6f 20 61 | forgett|ing.to a|
|000033f0| 73 73 69 67 6e 20 61 20 | 76 61 6c 75 65 20 74 6f |ssign a |value to|
|00003400| 20 61 20 76 61 72 69 61 | 62 6c 65 2c 20 6f 72 20 | a varia|ble, or |
|00003410| 74 6f 20 67 69 76 65 20 | 69 74 20 61 20 64 65 66 |to give |it a def|
|00003420| 61 75 6c 74 20 76 61 6c | 75 65 20 69 66 20 6e 6f |ault val|ue if no|
|00003430| 20 76 61 6c 75 65 20 77 | 61 73 0d 65 76 65 72 20 | value w|as.ever |
|00003440| 61 73 73 69 67 6e 65 64 | 2e 20 54 68 65 20 74 65 |assigned|. The te|
|00003450| 73 74 73 20 66 6f 72 20 | 74 68 69 73 20 61 72 65 |sts for |this are|
|00003460| 3a 0d 09 09 69 66 3a 09 | 09 09 09 09 09 09 09 09 |:...if:.|........|
|00003470| 09 74 68 65 6e 20 74 68 | 69 73 20 74 65 73 74 20 |.then th|is test |
|00003480| 69 73 20 74 72 75 65 3a | 0d 09 09 2d 2d 2d 2d 2d |is true:|...-----|
|00003490| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 09 09 2d 2d 2d 2d |--------|--..----|
|000034a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000034b0| 2d 2d 2d 0d 09 09 78 20 | 69 73 20 75 6e 61 73 73 |---...x |is unass|
|000034c0| 69 67 6e 65 64 09 09 09 | 09 69 66 20 28 78 20 3d |igned...|.if (x =|
|000034d0| 3d 20 22 22 20 26 26 20 | 78 20 3d 3d 20 30 29 0d |= "" && |x == 0).|
|000034e0| 09 09 78 20 3d 20 61 6e | 79 74 68 69 6e 67 09 09 |..x = an|ything..|
|000034f0| 09 09 09 69 66 20 28 78 | 20 21 3d 20 30 20 7c 7c |...if (x| != 0 |||
|00003500| 20 78 20 21 3d 20 22 22 | 29 0d 0d 46 6f 72 20 65 | x != ""|)..For e|
|00003510| 78 61 6d 70 6c 65 2c 0d | 09 69 66 20 28 66 69 6e |xample,.|.if (fin|
|00003520| 64 20 3d 3d 20 22 22 20 | 26 26 20 66 69 6e 64 20 |d == "" |&& find |
|00003530| 3d 3d 20 30 29 0d 09 09 | 70 72 69 6e 74 20 22 4f |== 0)...|print "O|
|00003540| 6f 70 73 2c 20 66 6f 72 | 67 6f 74 20 74 6f 20 73 |ops, for|got to s|
|00003550| 65 74 20 5c 22 66 69 6e | 64 5c 22 2e 22 0d 4d 6f |et \"fin|d\".".Mo|
|00003560| 72 65 20 63 6f 6d 6d 6f | 6e 6c 79 2c 20 79 6f 75 |re commo|nly, you|
|00003570| 27 6c 6c 20 6a 75 73 74 | 20 62 65 20 69 6e 74 65 |'ll just| be inte|
|00003580| 72 65 73 74 65 64 20 69 | 6e 20 77 68 65 74 68 65 |rested i|n whethe|
|00003590| 72 20 61 20 76 61 72 69 | 61 62 6c 65 20 68 61 73 |r a vari|able has|
|000035a0| 0d 61 20 6e 6f 6e 2d 6e | 75 6c 6c 20 76 61 6c 75 |.a non-n|ull valu|
|000035b0| 65 2c 20 66 6f 72 20 77 | 68 69 63 68 20 74 68 65 |e, for w|hich the|
|000035c0| 20 74 65 73 74 0d 09 69 | 66 20 28 78 20 3d 3d 20 | test..i|f (x == |
|000035d0| 22 22 29 0d 77 69 6c 6c | 20 64 6f 2e 0d 0d 43 6f |"").will| do...Co|
|000035e0| 6d 70 61 72 69 6e 67 20 | 73 74 72 69 6e 67 20 77 |mparing |string w|
|000035f0| 69 74 68 20 6e 75 6d 62 | 65 72 3a 20 69 6e 20 61 |ith numb|er: in a|
|00003600| 20 63 6f 6d 70 61 72 69 | 73 6f 6e 20 73 75 63 68 | compari|son such|
|00003610| 20 61 73 0d 09 69 66 20 | 28 78 20 3d 3d 20 79 29 | as..if |(x == y)|
|00003620| 20 6f 72 20 69 66 20 28 | 78 20 3e 3d 20 79 29 20 | or if (|x >= y) |
|00003630| 65 74 63 0d 78 20 61 6e | 64 20 79 20 61 72 65 20 |etc.x an|d y are |
|00003640| 63 6f 6d 70 61 72 65 64 | 20 61 73 20 73 74 72 69 |compared| as stri|
|00003650| 6e 67 73 20 75 6e 6c 65 | 73 73 20 62 6f 74 68 20 |ngs unle|ss both |
|00003660| 78 20 61 6e 64 20 79 20 | 61 72 65 20 6e 75 6d 62 |x and y |are numb|
|00003670| 65 72 73 2e 0d 54 6f 20 | 66 6f 72 63 65 20 74 68 |ers..To |force th|
|00003680| 65 20 63 6f 6d 70 61 72 | 69 73 6f 6e 20 74 6f 20 |e compar|ison to |
|00003690| 62 65 20 64 6f 6e 65 20 | 77 69 74 68 20 74 68 65 |be done |with the|
|000036a0| 20 6e 75 6d 65 72 69 63 | 20 76 61 6c 75 65 73 20 | numeric| values |
|000036b0| 6f 66 20 74 68 65 0d 76 | 61 72 69 61 62 6c 65 73 |of the.v|ariables|
|000036c0| 2c 20 61 64 64 20 30 20 | 74 6f 20 65 61 63 68 2c |, add 0 |to each,|
|000036d0| 20 61 73 20 69 6e 0d 09 | 69 66 20 28 78 2b 30 20 | as in..|if (x+0 |
|000036e0| 3d 3d 20 79 2b 30 29 20 | 6f 72 20 69 66 20 28 78 |== y+0) |or if (x|
|000036f0| 2b 30 20 3e 3d 20 79 2b | 30 29 2e 0d 43 6f 6e 76 |+0 >= y+|0)..Conv|
|00003700| 65 72 73 65 6c 79 2c 20 | 74 6f 20 66 6f 72 63 65 |ersely, |to force|
|00003710| 20 74 68 65 20 63 6f 6d | 70 61 72 69 73 6f 6e 20 | the com|parison |
|00003720| 74 6f 20 62 65 20 64 6f | 6e 65 20 77 69 74 68 20 |to be do|ne with |
|00003730| 74 68 65 20 73 74 72 69 | 6e 67 20 76 61 6c 75 65 |the stri|ng value|
|00003740| 73 2c 0d 63 6f 6e 63 61 | 74 65 6e 61 74 65 20 61 |s,.conca|tenate a|
|00003750| 74 20 6c 65 61 73 74 20 | 6f 6e 65 20 77 69 74 68 |t least |one with|
|00003760| 20 74 68 65 20 6e 75 6c | 6c 20 73 74 72 69 6e 67 | the nul|l string|
|00003770| 2c 20 61 73 20 69 6e 0d | 09 69 66 20 28 78 20 22 |, as in.|.if (x "|
|00003780| 22 20 3d 3d 20 79 29 20 | 6f 72 20 69 66 20 28 78 |" == y) |or if (x|
|00003790| 20 3e 3d 20 79 20 22 22 | 29 2e 0d 0d 47 6c 6f 62 | >= y ""|)...Glob|
|000037a0| 61 6c 20 69 6e 73 74 65 | 61 64 20 6f 66 20 6c 6f |al inste|ad of lo|
|000037b0| 63 61 6c 3a 20 69 66 20 | 79 6f 75 20 66 6f 72 67 |cal: if |you forg|
|000037c0| 65 74 20 74 6f 20 64 65 | 63 6c 61 72 65 20 61 20 |et to de|clare a |
|000037d0| 6c 6f 63 61 6c 20 76 61 | 72 69 61 62 6c 65 2c 20 |local va|riable, |
|000037e0| 6f 72 20 6d 69 73 73 70 | 65 6c 6c 0d 74 68 65 20 |or missp|ell.the |
|000037f0| 6e 61 6d 65 20 6f 66 20 | 61 20 6c 6f 63 61 6c 20 |name of |a local |
|00003800| 76 61 72 69 61 62 6c 65 | 2c 20 79 6f 75 72 20 76 |variable|, your v|
|00003810| 61 72 69 61 62 6c 65 20 | 77 69 6c 6c 20 62 65 20 |ariable |will be |
|00003820| 67 6c 6f 62 61 6c 20 72 | 61 74 68 65 72 20 74 68 |global r|ather th|
|00003830| 61 6e 0d 6c 6f 63 61 6c | 2e 20 49 74 20 77 69 6c |an.local|. It wil|
|00003840| 6c 20 6e 6f 74 20 62 65 | 20 69 6e 69 74 69 61 6c |l not be| initial|
|00003850| 69 7a 65 64 20 74 6f 20 | 7a 65 72 6f 20 65 61 63 |ized to |zero eac|
|00003860| 68 20 74 69 6d 65 20 79 | 6f 75 20 63 61 6c 6c 20 |h time y|ou call |
|00003870| 74 68 65 20 66 75 6e 63 | 74 69 6f 6e 2c 20 61 6e |the func|tion, an|
|00003880| 64 0d 69 66 20 69 74 20 | 69 73 20 75 73 65 64 20 |d.if it |is used |
|00003890| 65 6c 73 65 77 68 65 72 | 65 20 61 73 20 61 20 67 |elsewher|e as a g|
|000038a0| 6c 6f 62 61 6c 20 74 68 | 65 6e 20 63 68 61 6e 67 |lobal th|en chang|
|000038b0| 69 6e 67 20 69 74 73 20 | 76 61 6c 75 65 20 69 6e |ing its |value in|
|000038c0| 20 6f 6e 65 20 70 6c 61 | 63 65 20 77 69 6c 6c 0d | one pla|ce will.|
|000038d0| 61 66 66 65 63 74 20 74 | 68 65 20 6f 74 68 65 72 |affect t|he other|
|000038e0| 20 70 6c 61 63 65 2e 20 | 24 57 6f 72 64 46 72 65 | place. |$WordFre|
|000038f0| 71 75 65 6e 63 79 20 68 | 65 6c 70 73 20 77 69 74 |quency h|elps wit|
|00003900| 68 20 6d 69 73 73 70 65 | 6c 6c 69 6e 67 73 20 28 |h misspe|llings (|
|00003910| 73 65 65 20 61 62 6f 76 | 65 29 2e 0d 0d 46 75 6e |see abov|e)...Fun|
|00003920| 63 74 69 6f 6e 20 72 65 | 74 75 72 6e 73 20 67 61 |ction re|turns ga|
|00003930| 72 62 61 67 65 3a 20 69 | 66 20 79 6f 75 20 66 6f |rbage: i|f you fo|
|00003940| 72 67 65 74 20 74 6f 20 | 72 65 74 75 72 6e 20 73 |rget to |return s|
|00003950| 6f 6d 65 74 68 69 6e 67 | 20 66 72 6f 6d 20 61 20 |omething| from a |
|00003960| 66 75 6e 63 74 69 6f 6e | 0d 74 68 65 6e 20 74 68 |function|.then th|
|00003970| 65 20 72 65 74 75 72 6e | 65 64 20 76 61 6c 75 65 |e return|ed value|
|00003980| 20 6f 66 20 74 68 65 20 | 66 75 6e 63 74 69 6f 6e | of the |function|
|00003990| 20 77 69 6c 6c 20 62 65 | 20 67 61 72 62 61 67 65 | will be| garbage|
|000039a0| 2e 20 49 66 20 79 6f 75 | 72 20 66 75 6e 63 74 69 |. If you|r functi|
|000039b0| 6f 6e 0d 73 68 6f 75 6c | 64 20 72 65 74 75 72 6e |on.shoul|d return|
|000039c0| 20 73 6f 6d 65 74 68 69 | 6e 67 2c 20 63 68 65 63 | somethi|ng, chec|
|000039d0| 6b 20 74 68 61 74 20 69 | 74 20 64 6f 65 73 20 73 |k that i|t does s|
|000039e0| 6f 20 69 6e 20 61 6c 6c | 20 70 6f 73 73 69 62 6c |o in all| possibl|
|000039f0| 65 20 63 61 73 65 73 2e | 0d 0d 50 61 74 74 65 72 |e cases.|..Patter|
|00003a00| 6e 73 20 61 72 65 20 6e | 6f 74 20 6d 75 74 75 61 |ns are n|ot mutua|
|00003a10| 6c 6c 79 20 65 78 63 6c | 75 73 69 76 65 3a 20 6d |lly excl|usive: m|
|00003a20| 6f 72 65 20 6f 66 20 61 | 20 64 65 73 69 67 6e 20 |ore of a| design |
|00003a30| 70 72 6f 62 6c 65 6d 20 | 74 68 61 6e 20 61 20 62 |problem |than a b|
|00003a40| 75 67 2c 0d 74 68 65 20 | 70 72 6f 62 6c 65 6d 20 |ug,.the |problem |
|00003a50| 68 65 72 65 20 69 73 20 | 74 6f 20 65 78 65 63 75 |here is |to execu|
|00003a60| 74 65 20 6f 6e 65 20 61 | 63 74 69 6f 6e 20 69 66 |te one a|ction if|
|00003a70| 20 73 6f 6d 65 20 63 6f | 6d 70 6c 69 63 61 74 65 | some co|mplicate|
|00003a80| 64 20 74 65 73 74 20 69 | 73 20 74 72 75 65 2c 0d |d test i|s true,.|
|00003a90| 61 6e 64 20 64 6f 20 73 | 6f 6d 65 20 6f 74 68 65 |and do s|ome othe|
|00003aa0| 72 20 61 63 74 69 6f 6e | 20 6f 74 68 65 72 77 69 |r action| otherwi|
|00003ab0| 73 65 2e 20 54 6f 20 64 | 6f 20 69 74 2c 20 70 75 |se. To d|o it, pu|
|00003ac0| 74 20 61 6c 6c 20 74 68 | 65 20 63 6f 6d 70 6c 69 |t all th|e compli|
|00003ad0| 63 61 74 65 64 20 74 65 | 73 74 69 6e 67 0d 69 6e |cated te|sting.in|
|00003ae0| 73 69 64 65 20 6f 6e 65 | 20 61 63 74 69 6f 6e 2c |side one| action,|
|00003af0| 20 73 6f 20 79 6f 75 20 | 63 61 6e 20 75 73 65 20 | so you |can use |
|00003b00| 61 6e 20 22 69 66 2d 65 | 6c 73 65 22 20 63 6f 6e |an "if-e|lse" con|
|00003b10| 73 74 72 75 63 74 69 6f | 6e 2e 20 0d 41 6c 6c 20 |structio|n. .All |
|00003b20| 70 61 74 74 65 72 6e 73 | 20 69 6e 20 79 6f 75 72 |patterns| in your|
|00003b30| 20 70 72 6f 67 72 61 6d | 20 61 72 65 20 65 78 65 | program| are exe|
|00003b40| 63 75 74 65 64 20 66 6f | 72 20 65 61 63 68 20 6e |cuted fo|r each n|
|00003b50| 65 77 20 69 6e 70 75 74 | 20 6c 69 6e 65 2c 20 75 |ew input| line, u|
|00003b60| 6e 6c 65 73 73 0d 79 6f | 75 20 64 6f 20 6f 6e 65 |nless.yo|u do one|
|00003b70| 20 6f 66 3a 0d 09 22 6e | 65 78 74 22 2c 20 77 68 | of:.."n|ext", wh|
|00003b80| 69 63 68 20 72 65 74 72 | 69 65 76 65 73 20 74 68 |ich retr|ieves th|
|00003b90| 65 20 6e 65 78 74 20 69 | 6e 70 75 74 20 6c 69 6e |e next i|nput lin|
|00003ba0| 65 20 61 6e 64 20 73 74 | 61 72 74 73 20 74 68 65 |e and st|arts the|
|00003bb0| 20 70 61 74 74 65 72 6e | 0d 09 6d 61 74 63 68 69 | pattern|..matchi|
|00003bc0| 6e 67 20 6f 76 65 72 20 | 77 69 74 68 20 79 6f 75 |ng over |with you|
|00003bd0| 72 20 66 69 72 73 74 20 | 70 61 74 74 65 72 6e 3b |r first |pattern;|
|00003be0| 0d 09 22 67 65 74 6c 69 | 6e 65 22 2c 20 77 68 69 |.."getli|ne", whi|
|00003bf0| 63 68 20 72 65 74 72 69 | 65 76 65 73 20 74 68 65 |ch retri|eves the|
|00003c00| 20 6e 65 78 74 20 69 6e | 70 75 74 20 6c 69 6e 65 | next in|put line|
|00003c10| 20 74 6f 20 24 30 20 28 | 69 66 20 6e 6f 20 76 61 | to $0 (|if no va|
|00003c20| 72 69 61 62 6c 65 0d 09 | 69 73 20 73 70 65 63 69 |riable..|is speci|
|00003c30| 66 69 65 64 29 20 62 75 | 74 20 64 6f 65 73 6e 27 |fied) bu|t doesn'|
|00003c40| 74 20 6a 75 6d 70 20 79 | 6f 75 20 62 61 63 6b 20 |t jump y|ou back |
|00003c50| 74 6f 20 74 68 65 20 66 | 69 72 73 74 20 70 61 74 |to the f|irst pat|
|00003c60| 74 65 72 6e 3b 0d 09 22 | 65 78 69 74 22 20 77 68 |tern;.."|exit" wh|
|00003c70| 69 63 68 20 73 6b 69 70 | 73 20 74 6f 20 79 6f 75 |ich skip|s to you|
|00003c80| 72 20 45 4e 44 20 73 74 | 61 74 65 6d 65 6e 74 73 |r END st|atements|
|00003c90| 20 6f 72 20 65 78 69 74 | 73 20 69 6d 6d 65 64 69 | or exit|s immedi|
|00003ca0| 61 74 65 6c 79 2e 0d 09 | 09 0d 45 78 69 74 20 64 |ately...|..Exit d|
|00003cb0| 6f 65 73 6e 27 74 20 65 | 78 69 74 3a 20 61 6e 20 |oesn't e|xit: an |
|00003cc0| 22 65 78 69 74 22 20 69 | 6e 73 69 64 65 20 61 6e |"exit" i|nside an|
|00003cd0| 20 45 4e 44 20 62 6c 6f | 63 6b 20 64 6f 65 73 20 | END blo|ck does |
|00003ce0| 74 72 75 6c 79 20 61 6e | 64 20 69 6d 6d 65 64 69 |truly an|d immedi|
|00003cf0| 61 74 65 6c 79 0d 65 78 | 69 74 2e 20 41 6e 20 65 |ately.ex|it. An e|
|00003d00| 78 69 74 20 61 6e 79 77 | 68 65 72 65 20 65 6c 73 |xit anyw|here els|
|00003d10| 65 20 70 61 73 73 65 73 | 20 63 6f 6e 74 72 6f 6c |e passes| control|
|00003d20| 20 74 6f 20 79 6f 75 72 | 20 45 4e 44 20 73 74 61 | to your| END sta|
|00003d30| 74 65 6d 65 6e 74 73 20 | 69 66 20 74 68 65 72 65 |tements |if there|
|00003d40| 0d 61 72 65 20 61 6e 79 | 2c 20 73 6f 20 69 66 20 |.are any|, so if |
|00003d50| 79 6f 75 20 6e 65 65 64 | 20 74 6f 20 64 6f 20 61 |you need| to do a|
|00003d60| 6e 20 69 6d 6d 65 64 69 | 61 74 65 20 65 78 69 74 |n immedi|ate exit|
|00003d70| 20 69 6e 20 61 20 70 72 | 6f 67 72 61 6d 20 74 68 | in a pr|ogram th|
|00003d80| 61 74 20 63 6f 6e 74 61 | 69 6e 73 0d 61 6e 20 45 |at conta|ins.an E|
|00003d90| 4e 44 20 62 6c 6f 63 6b | 20 75 73 65 20 73 6f 6d |ND block| use som|
|00003da0| 65 74 68 69 6e 67 20 6c | 69 6b 65 0d 09 2e 2e 2e |ething l|ike.....|
|00003db0| 0d 09 69 66 20 28 73 68 | 6f 75 6c 64 20 69 6d 6d |..if (sh|ould imm|
|00003dc0| 65 64 69 61 74 65 6c 79 | 20 65 78 69 74 29 0d 09 |ediately| exit)..|
|00003dd0| 09 7b 0d 09 09 65 78 69 | 74 5f 6e 6f 77 20 3d 20 |.{...exi|t_now = |
|00003de0| 31 0d 09 09 65 78 69 74 | 0d 09 09 7d 0d 09 2e 2e |1...exit|...}....|
|00003df0| 2e 0d 09 45 4e 44 20 7b | 0d 09 09 69 66 20 28 65 |...END {|...if (e|
|00003e00| 78 69 74 5f 6e 6f 77 20 | 3d 3d 20 31 29 0d 09 09 |xit_now |== 1)...|
|00003e10| 09 65 78 69 74 0d 09 09 | 2e 2e 2e 6e 6f 72 6d 61 |.exit...|...norma|
|00003e20| 6c 20 45 4e 44 20 61 63 | 74 69 6f 6e 73 0d 09 09 |l END ac|tions...|
|00003e30| 7d 0d 0d 52 65 67 75 6c | 61 72 20 65 78 70 72 65 |}..Regul|ar expre|
|00003e40| 73 73 69 6f 6e 20 6d 61 | 74 63 68 65 73 20 74 6f |ssion ma|tches to|
|00003e50| 6f 20 6d 75 63 68 3a 20 | 72 65 67 75 6c 61 72 20 |o much: |regular |
|00003e60| 65 78 70 72 65 73 73 69 | 6f 6e 73 20 74 72 79 20 |expressi|ons try |
|00003e70| 74 6f 20 6d 61 74 63 68 | 0d 61 73 20 6d 75 63 68 |to match|.as much|
|00003e80| 20 61 73 20 70 6f 73 73 | 69 62 6c 65 20 2d 20 66 | as poss|ible - f|
|00003e90| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 2f 41 2e 2a |or examp|le, /A.*|
|00003ea0| 42 2f 20 77 69 6c 6c 20 | 6d 61 74 63 68 20 65 76 |B/ will |match ev|
|00003eb0| 65 72 79 74 68 69 6e 67 | 20 62 65 74 77 65 65 6e |erything| between|
|00003ec0| 0d 74 68 65 20 66 69 72 | 73 74 20 22 41 22 20 6f |.the fir|st "A" o|
|00003ed0| 6e 20 74 68 65 20 6c 69 | 6e 65 20 61 6e 64 20 74 |n the li|ne and t|
|00003ee0| 68 65 20 6c 61 73 74 20 | 22 42 22 20 6f 6e 20 74 |he last |"B" on t|
|00003ef0| 68 65 20 6c 69 6e 65 2c | 20 65 76 65 6e 20 69 66 |he line,| even if|
|00003f00| 20 74 68 65 72 65 20 61 | 72 65 20 35 20 42 27 73 | there a|re 5 B's|
|00003f10| 0d 69 6e 20 62 65 74 77 | 65 65 6e 2e 20 54 6f 20 |.in betw|een. To |
|00003f20| 6d 61 74 63 68 20 66 72 | 6f 6d 20 41 20 74 6f 20 |match fr|om A to |
|00003f30| 74 68 65 20 66 69 72 73 | 74 20 42 2c 20 75 73 65 |the firs|t B, use|
|00003f40| 20 2f 41 5b 5e 42 5d 2a | 42 2f 2e 0d 0d 4d 61 74 | /A[^B]*|B/...Mat|
|00003f50| 63 68 69 6e 67 20 43 20 | 69 64 65 6e 74 69 66 69 |ching C |identifi|
|00003f60| 65 72 73 3a 20 22 5c 77 | 22 20 69 6e 20 61 20 72 |ers: "\w|" in a r|
|00003f70| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|00003f80| 6e 20 69 73 20 74 68 65 | 20 73 61 6d 65 20 61 73 |n is the| same as|
|00003f90| 0d 22 5b 41 2d 5a 61 2d | 7a 30 2d 39 5d 22 20 2d |."[A-Za-|z0-9]" -|
|00003fa0| 20 6e 6f 74 65 20 69 74 | 20 64 6f 65 73 6e 27 74 | note it| doesn't|
|00003fb0| 20 69 6e 63 6c 75 64 65 | 20 74 68 65 20 75 6e 64 | include| the und|
|00003fc0| 65 72 73 63 6f 72 65 2e | 20 54 6f 20 6d 61 74 63 |erscore.| To matc|
|00003fd0| 68 20 61 20 43 0d 6e 61 | 6d 65 2c 20 75 73 65 20 |h a C.na|me, use |
|00003fe0| 22 5b 41 2d 5a 61 2d 7a | 5f 5d 5b 41 2d 5a 61 2d |"[A-Za-z|_][A-Za-|
|00003ff0| 7a 30 2d 39 5f 5d 2a 22 | 20 6f 72 20 74 68 65 20 |z0-9_]*"| or the |
|00004000| 65 71 75 69 76 61 6c 65 | 6e 74 0d 22 5b 41 2d 5a |equivale|nt."[A-Z|
|00004010| 61 2d 7a 5f 5d 28 5c 77 | 7c 5f 29 2a 22 2e 20 55 |a-z_](\w||_)*". U|
|00004020| 73 69 6e 67 20 22 5b 41 | 2d 5a 61 2d 7a 30 2d 39 |sing "[A|-Za-z0-9|
|00004030| 5f 5d 2b 22 20 77 69 6c | 6c 20 77 6f 72 6b 20 70 |_]+" wil|l work p|
|00004040| 72 6f 76 69 64 65 64 0d | 79 6f 75 20 64 6f 6e 27 |rovided.|you don'|
|00004050| 74 20 6d 69 6e 64 20 63 | 61 74 63 68 69 6e 67 20 |t mind c|atching |
|00004060| 69 6e 74 65 67 65 72 73 | 20 73 75 63 68 20 61 73 |integers| such as|
|00004070| 20 22 30 22 20 6f 72 20 | 22 33 31 37 22 20 61 73 | "0" or |"317" as|
|00004080| 20 77 65 6c 6c 20 61 73 | 20 6e 61 6d 65 73 2e 0d | well as| names..|
|00004090| 0d 4d 69 73 73 69 6e 67 | 20 61 72 72 61 79 20 69 |.Missing| array i|
|000040a0| 6e 64 65 78 3a 20 63 6f | 6e 73 69 64 65 72 20 74 |ndex: co|nsider t|
|000040b0| 68 65 20 66 72 61 67 6d | 65 6e 74 0d 09 78 5b 31 |he fragm|ent..x[1|
|000040c0| 5d 3d 20 31 37 0d 09 78 | 20 3d 20 22 68 75 68 3f |]= 17..x| = "huh?|
|000040d0| 22 0d 09 78 5b 32 5d 20 | 3d 20 22 68 69 22 0d 09 |"..x[2] |= "hi"..|
|000040e0| 70 72 69 6e 74 20 78 5b | 31 5d 2c 20 78 5b 32 5d |print x[|1], x[2]|
|000040f0| 2c 20 78 0d 2d 77 69 6c | 6c 20 74 68 69 73 20 72 |, x.-wil|l this r|
|00004100| 75 6e 3f 20 59 6f 75 20 | 62 65 74 20 2d 20 61 20 |un? You |bet - a |
|00004110| 76 61 72 69 61 62 6c 65 | 20 61 6e 64 20 61 6e 20 |variable| and an |
|00004120| 61 72 72 61 79 20 63 61 | 6e 20 68 61 76 65 20 74 |array ca|n have t|
|00004130| 68 65 20 73 61 6d 65 20 | 6e 61 6d 65 2c 0d 77 69 |he same |name,.wi|
|00004140| 74 68 20 6e 6f 20 69 6e | 74 65 72 66 65 72 65 6e |th no in|terferen|
|00004150| 63 65 20 62 65 74 77 65 | 65 6e 20 74 68 65 20 74 |ce betwe|en the t|
|00004160| 77 6f 2e 20 54 68 65 20 | 61 62 6f 76 65 20 66 72 |wo. The |above fr|
|00004170| 61 67 6d 65 6e 74 20 77 | 69 6c 6c 20 70 72 69 6e |agment w|ill prin|
|00004180| 74 0d 09 31 37 20 68 69 | 20 68 75 68 3f 0d 4e 65 |t..17 hi| huh?.Ne|
|00004190| 65 64 6c 65 73 73 20 74 | 6f 20 73 61 79 2c 20 74 |edless t|o say, t|
|000041a0| 68 69 73 20 22 66 65 61 | 74 75 72 65 22 20 73 68 |his "fea|ture" sh|
|000041b0| 6f 75 6c 64 20 62 65 20 | 61 76 6f 69 64 65 64 2e |ould be |avoided.|
|000041c0| 0d 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000041f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004200| 00 00 01 00 00 00 01 c4 | 00 00 00 c4 00 00 00 82 |........|........|
|00004210| 79 20 62 65 20 64 69 66 | 66 69 63 75 6c 74 20 74 |y be dif|ficult t|
|00004220| 6f 0d 64 69 61 67 6e 6f | 73 65 00 00 00 00 00 00 |o.diagno|se......|
|00004230| 17 44 65 62 75 67 67 69 | 6e 67 20 68 41 57 4b 20 |.Debuggi|ng hAWK |
|00004240| 70 72 6f 67 72 61 6d 73 | 02 00 00 00 54 45 58 54 |programs|....TEXT|
|00004250| 00 00 54 45 58 54 4b 45 | 45 4e 01 00 00 34 00 80 |..TEXTKE|EN...4..|
|00004260| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004270| 00 00 a5 cd 9e f3 00 00 | 41 41 00 00 02 46 00 00 |........|AA...F..|
|00004280| 00 82 00 06 b4 dc 06 9e | 00 00 00 1c 00 82 00 04 |........|........|
|00004290| 45 46 4e 54 00 00 00 2a | 4a 41 47 5a 00 00 00 36 |EFNT...*|JAGZ...6|
|000042a0| 57 53 49 5a 00 00 00 42 | 55 53 45 58 00 00 00 4e |WSIZ...B|USEX...N|
|000042b0| 41 4f 4e 4d 00 00 00 5a | 03 eb ff ff 00 00 00 00 |AONM...Z|........|
|000042c0| 00 07 1b ec 03 ed ff ff | 00 00 00 0e 00 07 1b f0 |........|........|
|000042d0| 03 ee ff ff 00 00 00 16 | 00 07 1b f8 03 f1 ff ff |........|........|
|000042e0| 00 00 00 22 00 07 1b fc | 03 f2 ff ff 00 00 00 8a |..."....|........|
|000042f0| 00 07 1b f4 00 00 13 86 | 00 00 0d fd 00 00 10 c2 |........|........|
|00004300| 00 00 00 04 00 03 00 04 | 00 00 00 96 00 05 00 00 |........|........|
|00004310| 04 e1 00 00 04 ef 13 61 | 20 20 20 49 74 20 64 6f |.......a| It do|
|00004320| 65 73 6e 27 74 20 72 75 | 6e 00 00 00 0b c9 00 00 |esn't ru|n.......|
|00004330| 0b e4 1f 62 20 20 20 49 | 74 20 64 6f 65 73 6e 27 |...b I|t doesn'|
|00004340| 74 20 64 6f 20 77 68 61 | 74 20 49 20 77 61 6e 74 |t do wha|t I want|
|00004350| 65 64 00 00 16 a6 00 00 | 16 b0 11 62 20 20 31 20 |ed......|...b 1 |
|00004360| 20 20 41 73 73 65 72 74 | 69 6f 6e 73 00 00 1e 8d | Assert|ions....|
|00004370| 00 00 1e 9a 15 62 20 20 | 32 20 20 20 46 75 6e 63 |.....b |2 Func|
|00004380| 74 69 6f 6e 20 66 6c 6f | 77 00 00 00 2a 46 00 00 |tion flo|w...*F..|
|00004390| 2a 51 0f 63 20 20 20 43 | 6f 6d 6d 6f 6e 20 62 75 |*Q.c C|ommon bu|
|000043a0| 67 73 00 00 00 0a 00 0a | 06 47 65 6e 65 76 61 00 |gs......|.Geneva.|
|000043b0| 00 00 00 04 a6 04 94 0e | 00 00 00 08 00 4f 00 36 |........|.....O.6|
|000043c0| 01 3d 01 d4 00 00 01 00 | 00 00 01 c4 00 00 00 c4 |.=......|........|
|000043d0| 00 00 00 82 00 1a 83 18 | 05 e2 00 00 00 1c 00 82 |........|........|
|000043e0| 00 04 45 54 41 42 00 00 | 00 2a 4d 50 53 52 00 00 |..ETAB..|.*MPSR..|
|000043f0| 00 36 45 46 4e 54 00 00 | 00 42 4a 41 47 5a 00 00 |.6EFNT..|.BJAGZ..|
|00004400| 00 4e 57 53 49 5a 00 00 | 00 5a 03 ec ff ff 00 00 |.NWSIZ..|.Z......|
|00004410| 00 00 00 1a 7e fc 03 ef | ff ff 00 00 00 08 00 1a |....~...|........|
|00004420| 7f 20 03 eb ff ff 00 00 | 00 a2 00 1a 7f 08 03 ed |. ......|........|
|00004430| ff ff 00 00 00 b0 00 1a | 7e ec 03 ee ff ff 00 00 |........|~.......|
|00004440| 00 b8 00 1a 7e f0 00 00 | 00 00 00 00 00 00 00 00 |....~...|........|
|00004450| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004460| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004470| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+